0

我在我的应用程序中添加了一个 modalView,一切正常,但在关闭模式时,整个 modalView 在消失时向左跳跃约 1-2 厘米。

我还没有找到任何原因,所以这里是关于模态的代码:

应用控制器:

- (void) showNameModal:(Player *)player 
{
    namesModal = [[PlayerModalView alloc] init];
    namesModal.delegate = self;
    namesModal.player = player;

    UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:namesModal];

    navCon.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentModalViewController:navCon animated:YES];

    [navCon release];
    [namesModal release];
 }

 - (void)didDismissModalView 
 {
    [self dismissModalViewControllerAnimated:YES];
 }

模态视图:

 - (void)dismissView:(id)sender 
 {
    [delegate didDismissModalView];
 }

通过导航按钮以及通过键盘调用

  [self dismissView:nil];

如您所见,它没有什么特别之处,实际上可以从手册中获取。详细情况:

模态出现在屏幕中央,从底部滑入。一直居中。我可以在 modalView 中处理一些动作,它保持居中。

现在,关闭视图使其向左跳,而不是滑出。

由于它是一个强制横向右移的应用程序(目前),我只能通知左跳。

任何想法如何让这个跳跃?

谢谢

4

4 回答 4

0

试试这个,

- (void)didmissView:(id)sender
{
   [self.navigationController didmissModelViewControllerAnimated:YES];
}
于 2010-09-20T09:18:31.000 回答
0

您不是以模态方式呈现 的实例,PlayerModalView而是呈现UINavigationController. 您看到的左手抖动很可能是导航控制器尝试将幻灯片转换为(不存在的)先前视图的默认动画。

听起来您不需要用于PlayerModalView. 相反,您应该为它创建一个普通的视图控制器。

于 2010-09-20T12:59:08.013 回答
0

这个解决方案似乎运作良好:Modal View Controller with keyboard on Landscape iPad changes location when dismissed

为了简化第一响应者的辞职(如果很难找到),您可以致电

[self.view endEditing:YES];
[self dismissModalViewControllerAnimated:YES];
于 2011-01-21T19:37:37.823 回答
0

问题是UIViewController您以模态方式展示的方向不允许您展示它的方向,因此当它消失时,它将朝着它认为“允许”的方向进行。

将此添加到UIViewController为您的模式视图:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}
于 2012-08-03T09:38:35.173 回答