私はクラス内にこのメソッドを持っています。 [self shiftViewUpForKeyboard]を呼び出すと(このクラスの)サブクラスでどのように使用するのですか。それは引数を必要としますが、私がTheNotificationとタイプするとエラーになります。私はこれがおそらく非常に基本的だと知っていますが、それは本当に私のアプリ全体を通してたくさんの助けになります。サブクラス化されたメソッドを使用する方法
- (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 _];'を試しましたか? –