现在ScrollView里的TextField编辑弹出键盘,ScrollView上移的特效做好,可是TextView按照TextField的方法却没有效果(下面写出了TextField的方法,急需TextView编辑ScrollView上移到可显示位置的方法!!!)
【TextField】- (void)registerForKeyboardNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
}// Called when the UIKeyboardDidShowNotification is sent.
- (void)keyboardWasShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height + 70, 0.0);
_myScroolView.contentInset = contentInsets;
_myScroolView.scrollIndicatorInsets = contentInsets;
// If active text field is hidden by keyboard, scroll it so it's visible
// Your application might not need or want this behavior. CGRect aRect = self.view.frame;
aRect.size.height -= kbSize.height;// if (!CGRectContainsPoint(aRect, activeField.frame.origin) ) {
// CGPoint scrollPoint = CGPointMake(0.0, activeField.frame.origin.y-kbSize.height);
// [_myScroolView setContentOffset:scrollPoint animated:YES];
// }}// Called when the UIKeyboardWillHideNotification is sent
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{
UIEdgeInsets contentInsets = UIEdgeInsetsZero;
_myScroolView.contentInset = contentInsets;
_myScroolView.scrollIndicatorInsets = contentInsets;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
【TextView】???????????????????????????????????? 大神指点下~
【TextField】- (void)registerForKeyboardNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
}// Called when the UIKeyboardDidShowNotification is sent.
- (void)keyboardWasShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height + 70, 0.0);
_myScroolView.contentInset = contentInsets;
_myScroolView.scrollIndicatorInsets = contentInsets;
// If active text field is hidden by keyboard, scroll it so it's visible
// Your application might not need or want this behavior. CGRect aRect = self.view.frame;
aRect.size.height -= kbSize.height;// if (!CGRectContainsPoint(aRect, activeField.frame.origin) ) {
// CGPoint scrollPoint = CGPointMake(0.0, activeField.frame.origin.y-kbSize.height);
// [_myScroolView setContentOffset:scrollPoint animated:YES];
// }}// Called when the UIKeyboardWillHideNotification is sent
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{
UIEdgeInsets contentInsets = UIEdgeInsetsZero;
_myScroolView.contentInset = contentInsets;
_myScroolView.scrollIndicatorInsets = contentInsets;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
【TextView】???????????????????????????????????? 大神指点下~
解决方案 »
- IOS Apple APNS 消息推送 C#
- 平板电脑可以调试objective-c程序么?
- 请教一下IOS游戏中 视图控制器(ViewController)的层次关系
- 请问我想开发一个Iphone4和Iphone4S都能看到的很简单的一个新闻游览程序,应该学些什么东西,谢谢
- Xcode IOS ios怎么让文本显示成下面这样啊
- 请问 Fix issue 证书为什么下载错
- iOS 类名前缀, 个人喜好?
- ios中访问浏览器的cookie
- tableView与scrollView滑动冲突
- ios开发者账号申请卡在了法律协议确认界面!!!
- xcode持续集成问题_xcrun
- 急求转码。\u4e0a\u4f20\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5\uff01
这个第三方键盘监听完美解决所有遮挡问题