仅景观应用。在我的主窗口xib上,我有一个UIView。我正在以编程方式将UIScrollview加载到UIView中,它工作正常。在那个scrollview上,我有一个按钮,通过presentModalViewController调用调出一个“细节”屏幕(一个单独的视图控制器):
LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self presentModalViewController:learnit animated:YES];
[learnit release];
当滚动视图是子视图时,正在调用动作,但模态视图不占用整个屏幕。相反,它会弹出父卷轴视图并翻转方向等。不是所需的行为。
当调用来自scrollview时,有关如何使模态视图全屏的任何指导,它是主xib上容器UIView的子视图?
答案 0 :(得分:1)
感谢所有评论。在覆盖presentModalViewController的地方找到了一个提示,并在循环中冒泡,直到主控制器到达(在我的情况下,HomeViewController)。像冠军一样工作。
- (void) presentModalViewController:(UIViewController *)screen animated:(BOOL)animated {
UIResponder *responder = self;
while (responder && ![responder isKindOfClass:[HomeViewController class]]) {
responder = [responder nextResponder];
}
[(UIViewController *)responder presentModalViewController:screen animated:YES];
}
我正在覆盖UIScrollview的.m文件,其中包含拨打电话的按钮。
答案 1 :(得分:0)
尝试添加subview
,而不是presentModelViewController
:
LearnITViewController *tempView = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:[NSBundle mainBundle]];
self.learnITViewController = tempView;
[tempView release];
[self.view addSubview:mainMenuView.view];
并添加此
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);//or left
}
答案 2 :(得分:0)
LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self.learnitView setsetWantsFullScreenLayout:YES];
或
self.learnitView.wantsFullScreenLayout = YES;
[self presentModalViewController:learnit animated:YES];
[learnit release];
答案 3 :(得分:-2)
而不是self
在UIViewController
中添加superview
。
LearnITViewController *learnit = [[LearnITViewController alloc] initWithNibName:@"LearnITViewController" bundle:nil];
self.learnitView = learnit;
[self.view.superview presentModalViewController:learnit animated:YES];
[learnit release];