iphone - how to expand UITextview automatically based on displaying string in ios -


I have two text views whose data dynamically populates when the data pops up, I want to resize the shape so that I do not see a vertical book nor the text has been cut. I want to do this work programmatically.

  tViewhobbies = [[UITextView alloc] initWithFrame: CGRectMake (10, 330, 300, strSize.height + 20)]; TViewhobbies.backgroundColor = [UIColor clear collar]; TViewhobbies.layer.cornerRadius = 5; [T Weihoshobei set user interaction enabled: no]; TViewhobbies.font = [UIFont systemFontOfSize: 12.0]; TViewhobbies.backgroundColor = [UIColor colorWithRed: 0.662745 green: 0.662745 blue: 0.662745 alpha: 0.5]; TViewhobbies.delegate = self; TViewhobbies.scrollEnabled = Yes; [ScrollView Adsview: TVHobbies]; LblInterests = [[UILabel alloc] initWithFrame: CGRectMake (10, 410, 300, strSize.height + 0)]; LblInterests.text = @ "Interests"; LblInterests.font = [UIFont systemFontOfSize: 16.0]; LblInterests.textColor = [UIColor colorWithRed: 153.0F / 255.0f Green: 153.0F / 255.0F blue: 153.0F / 255.0F Alpha: 1]; [Add ScrollView Add Content: lblInterests]; TViewInterests = [[UITextView alloc] initWithFrame: CGRectMake (10, 430, 300, strSize.height + 30)]; TViewInterests.backgroundColor = [UIColor clear collar]; TViewInterests.layer.cornerRadius = 5; [TViewInterests setUserInteractionEnabled: NO]; TViewInterests.font = [UIFont systemFontOfSize: 14.0]; TViewInterests.backgroundColor = [UIColor colorWithRed: 0.662745 green: 0.662745 blue: 0.662745 alpha: 0.5]; TViewInterests.delegate = Self; TViewInterests.scrollEnabled = Yes; [Add ScrollView addviewview: tViewInterests];    

Try this:

  NSDictionary * attributes = @ {NSFontAttributeName: [UIFont systemFontOfSize: 14]}; CGRect rect = [aTextView.textBoundingRightWithSize: CGSizeMake (300, MaxFlat) option: NSStringDrawingUsesLineFragmentOrigin attributes: attribute reference: zero]; ATextView.frame = CGRectMake (0, 0,300, rect.size.height);    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -