在iPad应用中,如何在用户触摸时滚动uitextview?

时间:2017-08-21 14:54:11

标签: ios objective-c ipad xcode6 uitextview

我正在使用UITableView,并在其中添加了UITextView

我想将UITableView位移到键盘上方。

以下是我的代码:

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];


- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{

    NSCharacterSet *doneButtonCharacterSet = [NSCharacterSet newlineCharacterSet];
    NSRange replacementTextRange = [text rangeOfCharacterFromSet:doneButtonCharacterSet];
    NSUInteger location = replacementTextRange.location;

    if (textView.text.length + text.length > 250){
        if (location != NSNotFound){
            //self.view.frame= CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y+100, self.view.frame.size.width, self.view.frame.size.height);
            [textView resignFirstResponder];

        }
        return NO;
    }
    else if (location != NSNotFound){
        //self.view.frame= CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y+100, self.myTable.frame.size.width, self.myTable.frame.size.height);
        [textView resignFirstResponder];

        return NO;
    }
    return YES;
}

0 个答案:

没有答案