我有 TextField1 和 TextField2
我想仅在由于 TextField2 而显示键盘时滚动滚动视图。这是我的实际代码。
有什么解决办法吗?
-(void) viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidShow:)
name:UIKeyboardDidShowNotification
object:self.view.window];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDidHide:)
name:UIKeyboardDidHideNotification
object:nil];
}
-(void) keyboardDidShow:(NSNotification *) notification {
self.ScrollView.center = CGPointMake(self.originalCenter.x,
self.originalCenter.y-100);
}
-(void) keyboardDidHide:(NSNotification *) notification {
self.ScrollView.center = CGPointMake(self.originalCenter.x,
self.originalCenter.y);
}