I don't know how I can resize my cells in my UICollectionView when the UITextView within it becomes bigger while the user is writing (as I do in the following code :)
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if([text isEqualToString:@"\n"]){
float widthLabel = 0.0f;
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){
widthLabel = (screenWidth-6)-4-200;
}else if(UIInterfaceOrientationIsLandscape(interfaceOrientation)){
widthLabel = (screenHeight-24)-4-200;
}
textView.frame = CGRectMake(2, 0, widthLabel, textView.frame.size.height+10);
}
if(text.length == 0 && [[textView.text substringWithRange:range] isEqualToString:@"\n"]){
float widthLabel = 0.0f;
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){
widthLabel = (screenWidth-6)-4-200;
}else if(UIInterfaceOrientationIsLandscape(interfaceOrientation)){
widthLabel = (screenHeight-24)-4-200;
}
textView.frame = CGRectMake(2, 0, widthLabel, textView.frame.size.height-10);
}
return YES;
}
I would like to make the item cell which contains this UITextView become bigger/smaller with respect to the UITextView. I cannot change the size by stroing the new height fo the cell and use reloadData because it makes the keyboard go away and the user cannot write anymore.