我在這個類中有這個方法。我如何在我的子類(這個類)中使用它,因爲當我調用[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