このコードでナビゲーションコントローラーを提示しています(提示されているビューコントローラーの基本クラスで):
-(void)presentInNavigationControllerWithViewController:(UIViewController*)viewController
{
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self];
nav.modalPresentationStyle = UIModalPresentationFormSheet;
nav.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
nav.view.autoresizingMask = UIViewAnimationTransitionNone;
[viewController presentModalViewController:nav animated:YES];
CGRect rect = self.finalRect; /*desired size +44 height*/
CGRect windowRect = [self.view.window convertRect:self.view.window.frame toView:self.view];
rect.origin.y = (windowRect.size.height-rect.size.height)/2;
nav.view.superview.frame = rect;
}
ユーザーがテキストビューをクリックしたときに後でビューのサイズを変更するには:
// in viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillAppear:)
name:UIKeyboardWillShowNotification object:nil];
-(void)keyboardWillAppear:(NSNotification*)notification
{
UIView *view = self.navigationController.view.superview;
view.frame = CGRectMake(view.frame.origin.x + 200,
view.frame.origin.y,
view.frame.size.width-200,
view.frame.size.height);
}
ランドスケープ モードでは、結果としてview.frame.size.width-200
ビューの高さが 200 減少します (ビューのウィンドウがポートレート モードになっているためですか?)。もう 1 つの問題は、影がナビゲーション コントローラーより遅れることです。コードをアニメーション : に入れる[UIView animateWithDuration:0.25 animations:^{
と、影の代わりに灰色の四角形が遅れます。
これを行う正しい方法は何ですか? (できればアニメーション付き)