【问题标题】:Problem with position of new view using presentModalViewController使用 presentModalViewController 的新视图位置问题
【发布时间】:2011-08-18 06:39:17
【问题描述】:

我正在尝试使用 presentModalViewController 向我的应用添加新视图。

ASpotImageViewController *aSpotImage = [[ASpotImageViewController alloc] initWithNibName:@"ASpotImageView" bundle:nil spotID:spotid];
aSpotImage.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
//NSLog(@"frame is %@", aSpotImage.view.frame);
//NSLog(@"origin is %@", aSpotImage.view.frame.origin);
NSLog(@"description is %@", aSpotImage.description);
[aSpotImage setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:aSpotImage animated:YES];

但是当我使用它时,新视图出现在屏幕下方大约 40 像素左右,并且底部被切断。这可能是什么原因造成的?在我使用此代码的其他情况下,我没有这个问题。

【问题讨论】:

    标签: iphone objective-c modalviewcontroller viewcontroller


    【解决方案1】:

    您当前的容器具有(320,440,0,40) 的框架,因此当您出现在它上面时,它似乎被抵消了那么多,尽管实际上它只是将它添加到位置(0,0) 相对于父容器.解决方法是根据当前视图或父视图重新调整框架。

    【讨论】:

    • 我该怎么做?我尝试手动调整框架,但它似乎没有改变模态视图控制器中的任何内容。
    • 我在 iPad 上遇到了同样的问题,即使在横向模式下,如果我检查框架,它会告诉我 {0,0},{768,1024} 这是纵向模式的大小.
    【解决方案2】:

    Gurooj,你实现了吗?试试这个

    UINavigationController *nextController = [[UINavigationController alloc] initWithRootViewController:aSpotImage];
    [self presentModalViewController: nextController animated: YES];
    

    空白通常是导航栏的高度,我猜?

    【讨论】:

    • 这只会在屏幕上出现一个新的空白导航栏。它实际上留下了一个黑色空间,与我尝试推送的新视图颜色相同。但是父视图的背景是白色的。这只会让我更加困惑。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多