콘텐츠를 추가하는 데 사용되는 하위보기가 필요한 tableview가 있습니다. 하위 뷰에는 텍스트를 입력하는 데 사용되는 UITextView가 포함되어 있습니다. 이전 7.1 다음은 일어날 것 :iOS 7.1로 업데이트 한 후 동적 textView 크기가 깨졌습니다.
- 하위 뷰가 scrollViewDidScroll 활성화
- 통해있는 tableview의 바닥에 접착되어, 키보드보기는 키보드와 애니메이션을 보여 것
- 텍스트입니다 텍스트가 입력되면 textView는 필요한 경우 위쪽으로 확장되고 textView의 아래쪽은 그대로 유지됩니다. textViewDidEndEditing 트리거하고있어 GET,이
- 하위 뷰 대신 확장의,
- 텍스트가 새 줄을 강제하면 좋은 키보드 위쪽에 애니메이션을
NOW 7.1 후, 다음과 같은 동작이 발생 키보드가 닫힙니다.
- 텍스트 뷰에서 더 이상 편집 할 수 없으므로 편집하면 키보드가 즉시 닫힙니다.
7.1에서 변경된 사항에 대한 제안 사항으로 인해 기존 코드를 중단시킬 수 있습니까? 다음은 관련된 모든 코드입니다. 추가 세부 정보를 제공해 드리겠습니다. 나는 지금이 순간에 있었고 그것은 정신적으로 나를 몰고 간다.
tableViewController.m - 하위보기에 추가하는 코드입니다. 하위보기에는 자체 xib가 있습니다. xib은 IB에서 생성되었습니다. 다른 구성 요소와 관련된 부분을 제거했습니다. 당신이 무엇을보고 싶다면
- (void)viewDidLoad {
//Setup contentBar
if (self.contentBar == nil) {
//Add subView to View
NSArray *subviewArray = [[NSArray alloc] init];
subviewArray = [[NSBundle mainBundle] loadNibNamed:contentIdentifier owner:self options:nil];
self.contentBar = [subviewArray objectAtIndex:0];
[self.view addSubview:self.contentBar];
//Setup textView
UITextView *addContentTextView = (UITextView *)[self.contentBar viewWithTag:2];
addContentTextView.text = [NSString stringWithFormat:@"text (optional)"];
addContentTextView.delegate = self;
}
}
내 텍스트 뷰의 대표
#pragma mark - TextView Delegate
- (void)textViewDidEndEditing:(UITextView *)textView{
NSLog(@"textViewDidEndEditing:");
if ([textView.text isEqualToString:@""]) {
textView.text = @"text (optional)";
textView.textColor = [UIColor lightGrayColor]; //optional
}
[textView resignFirstResponder];
}
- (void)textViewDidBeginEditing:(UITextView *)textView {
NSLog(@"textViewDidBeginEditing:");
if ([textView.text isEqualToString:@"text (optional)"]) {
textView.text = @"";
textView.textColor = [UIColor blackColor]; //optional
}
[textView becomeFirstResponder];
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
NSString *newText = [textView.text stringByReplacingCharactersInRange:range withString:text];
if ([newText length] > 0 || _image) {
_addContentButton.enabled = YES;
} else {
_addContentButton.enabled = NO;
}
if([text isEqualToString:[text stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]]) {
return YES;
} else {
NSLog(@"return pressed");
[textView resignFirstResponder];
[self addedContent:nil];
}
return YES;
}
- (void)textViewDidChange:(UITextView *)textView
{
NSLog(@"textViewDidChange");
[self sizeTextView];
}
- (void)sizeTextView
{
NSLog(@"sizeTextView");
UIImageView *barImage = (UIImageView *)[self.contentBar viewWithTag:87];
UITextView *textView = (UITextView *)[self.contentBar viewWithTag:2];
CGSize sizeThatShouldFitTheContent = [textView sizeThatFits:textView.frame.size];
CGRect newTextViewFrame = textView.frame;
newTextViewFrame.size.height = sizeThatShouldFitTheContent.height;
CGFloat adjustment = sizeThatShouldFitTheContent.height - textView.frame.size.height;
newTextViewFrame.origin.y = textView.frame.origin.y - adjustment;
textView.frame = newTextViewFrame;
CGRect newImageViewFrame = barImage.frame;
newImageViewFrame.size.height = barImage.frame.size.height + adjustment;
newImageViewFrame.origin.y = barImage.frame.origin.y - adjustment;
barImage.frame = newImageViewFrame;
}
, 나는 그것을 게시 드리겠습니다.