【发布时间】:2012-06-22 21:07:36
【问题描述】:
我试图从我的一个视图中呈现一个模态视图。演示者视图已从自定义视图显示为模式。我的问题是我无法在新的模态视图中看到“完成”按钮。下面是我的代码。我错过了什么吗?
UIViewController *aViewController = [[UIViewController alloc] init];
UINavigationController *aNavigationController = [[[UINavigationController alloc] initWithRootViewController:aViewController] autorelease];
[aNavigationController.navigationBar setBarStyle:UIBarStyleBlack];
UIBarButtonItem *aBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissMe)];
[aNavigationController.navigationItem setLeftBarButtonItem:aBarButtonItem];
MyView *aView = [[MyView alloc] initWithFrame:self.view.frame];
[aViewController.view addSubview:aView];
[self presentModalViewController:aNavigationController animated:YES];
[aViewController release];
- (void)dismissMe {
[self dismissModalViewControllerAnimated:YES];
}
【问题讨论】:
-
我不认为像这样堆叠视图控制器是好的设计......但你的问题的答案在于navigationController.view.frame。尝试明确设置...如果可能,请在问题中添加图片。
-
我通过将框架设置为 CGRectMake(0, 0, 320, 400) 来做到这一点,但它没有帮助。
-
请添加图片。可能是aView遮住了屏幕。那帧大小呢?
-
添加了图片。请看一下 Q 本身。
-
如果将其设置为 (0, 44, 320, 416) 会发生什么? (我唯一的猜测是你的 aView 覆盖了导航栏视图)
标签: iphone objective-c cocoa-touch uiviewcontroller modalviewcontroller