I need UITextView fit to conent in ios 6, - Max width =250.0f; - heigth is FLT_MAX i was search and try so many times(found very many result in stackoverflow but it won't able). My code here :
UIView *returnView = [[UIView alloc] initWithFrame:CGRectZero];
UIFont *fon = [UIFont systemFontOfSize:13.0f];
UITextView *textView = [[UITextView alloc]init];
textView.textColor =[UIColor whiteColor];
textView.backgroundColor = [UIColor clearColor];
textView.text = message;
textView.font = fon;
[textView sizeToFit];
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1){
//in IOS7 it works perfectly
textView.layoutManager.allowsNonContiguousLayout = NO;
CGSize myTextViewSize = [textView sizeThatFits:CGSizeMake(250.0, FLT_MAX)];
textView.frame = CGRectMake(textView.frame.origin.x, textView.frame.origin.y, myTextViewSize.width, myTextViewSize.height);
returnView.frame = CGRectMake(0.0, 0.0, myTextViewSize.width, myTextViewSize.height);
}else{
//how to do ?
}
[returnView addSubview:textView];
return returnView;