我在这个类中有这个方法。我如何在我的子类(这个类)中使用它,因为当我调用[self shiftViewUpForKeyboard]时;它需要参数,但是当我输入通知时,它会给出错误。我知道这可能是非常基本的,但是在整个我的应用程序中它确实会帮助我很多。如何使用子类方法
- (void) shiftViewUpForKeyboard: (NSNotification*) theNotification;
{
CGRect keyboardFrame;
NSDictionary* userInfo = theNotification.userInfo;
keyboardSlideDuration = [[userInfo objectForKey: UIKeyboardAnimationDurationUserInfoKey] floatValue];
keyboardFrame = [[userInfo objectForKey: UIKeyboardFrameBeginUserInfoKey] CGRectValue];
UIInterfaceOrientation theStatusBarOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if UIInterfaceOrientationIsLandscape(theStatusBarOrientation)
keyboardShiftAmount = keyboardFrame.size.width;
else
keyboardShiftAmount = keyboardFrame.size.height;
[UIView beginAnimations: @"ShiftUp" context: nil];
[UIView setAnimationDuration: keyboardSlideDuration];
self.view.center = CGPointMake(self.view.center.x, self.view.center.y - keyboardShiftAmount);
[UIView commitAnimations];
viewShiftedForKeyboard = TRUE;
}
谢谢亲切!
你试过了吗?[self shiftViewUpForKeyboard:_theVariableYouWantToPass _];'? – 2012-04-28 08:05:42