【问题标题】:iphone 5 retina 4 inch mapviewiphone 5 视网膜 4 英寸地图视图
【发布时间】:2013-05-03 10:37:26
【问题描述】:

我正在尝试使我的应用程序适应 iPhone 5 的视网膜 4 屏幕,并添加 png 存档和所有调整大小,但地图视图会移动到顶部并在底部留下一个白色方块。我想知道如何解决它。

提前致谢。

也许这与它有关?

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    // We need to manually handle rotation on iPads running iOS 5 and higher to support the new UINavigationBar customization. This is automatic on the iPhone & iPod Touch.
    if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
        if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
            toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
            [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"UINavBarLandscape@iPad.png"] forBarMetrics:UIBarMetricsDefault];
        }
        else {
            [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"UINavBar@iPad.png"] forBarMetrics:UIBarMetricsDefault];
        }
    }
}
else {
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
        toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        [mapView setFrame:CGRectMake(0, 0, 480, 236)];
        [toolbar setFrame:CGRectMake(0, 236, 480, 32)];
    }
    else {
        [mapView setFrame:CGRectMake(0, 0, 320, 372)];
        [toolbar setFrame:CGRectMake(0, 372, 320, 44)];
    }

【问题讨论】:

    标签: objective-c xcode mkmapview


    【解决方案1】:

    对于顶部栏应锚定到顶部。底部栏固定在控制器视图的底部。地图视图应锚定在顶部和底部,但还应具有垂直弹簧。

    现在,当您拥有 iphone 4 或 5 时,一切都应该正确展开。

    另外,如果您的目标是 iOS 6,请花点时间使用 AutoLayout。这样当 iPhoneN 有不同的分辨率时,你就不必太担心布局了。

    【讨论】:

    • 嗨,约翰,我按照你说的做了所有事情……但它没有改变。还尝试使用 iOS 6.1 进行 alutolayout ......什么也没有。无论如何感谢您的建议:)
    • 我在问题中添加了一些代码......我认为这就是重点。
    • 好吧,您正在对 UI 的框架进行硬编码。你不应该那样做。由于您的目标是 iOS 5,因此您应该使用弹簧和支柱来解决这个问题。或者检查 iPhone 5 的尺寸并以这种方式更改框架。
    【解决方案2】:

    您必须以编程方式检查代码中的 iPhone 设备版本并相应地调整控件的大小。

    【讨论】:

      猜你喜欢
      • 2013-05-11
      • 2013-03-01
      • 2012-09-24
      • 1970-01-01
      • 2012-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-25
      相关资源
      最近更新 更多