iPhone 或 iPhone 5 位置中的条件语句更新 : method

标签 iphone ios objective-c uistoryboard

我在 locationUpdate: 方法中有这个 iPhone 或 iPhone 5 条件语句。

此代码有效:

- (void)locationUpdate:(CLLocation *)location {
    //locLabel.text = [location description];

#ifdef DEBUG    
    NSLog(@"auth status is %u", [CLLocationManager authorizationStatus]);
#endif


                UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
                OffersViewController *lvc = [storyboard instantiateViewControllerWithIdentifier:@"OffersViewController"];
                [self.navigationController pushViewController:lvc animated:NO];


}

但是当iphone5条件码。它失败。该应用程序不会崩溃,而只会保留在 View Controller (RootViewController) 上,并且不会推送到 OffersViewController 或 OffersViewControlleriPhone。
- (void)locationUpdate:(CLLocation *)location {
    //locLabel.text = [location description];

#ifdef DEBUG    
    NSLog(@"auth status is %u", [CLLocationManager authorizationStatus]);
#endif

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
        if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) {
            CGSize result = [[UIScreen mainScreen] bounds].size;
            CGFloat scale = [UIScreen mainScreen].scale;
            result = CGSizeMake(result.width * scale, result.height * scale);

            if(result.height == 960) {
                NSLog(@"iPhone 4 Resolution");

                UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
                OffersViewController *lvc = [storyboard instantiateViewControllerWithIdentifier:@"OffersViewController"];
                [self.navigationController pushViewController:lvc animated:NO];


            }
            **else if(result.height == 1136) {
                NSLog(@"iPhone 5 Resolution");

                UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
                OffersViewControlleriPhone5 *lvc = [storyboard instantiateViewControllerWithIdentifier:@"OffersViewControlleriPhone5"];
                [self.navigationController pushViewController:lvc animated:NO];

            }**
        }
        else {
            NSLog(@"Standard Resolution");

            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
            OffersViewController *lvc = [storyboard instantiateViewControllerWithIdentifier:@"OffersViewController"];
            [self.navigationController pushViewController:lvc animated:NO];


        }
    }

}

似乎是 iPhone5 的 else if 语句才是问题所在。即使我将 OffersViewControlleriPhone5 更改为 OffersViewController,它也不起作用。

谢谢你的帮助

最佳答案

刚刚想通了。我有一个 }关闭if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){ if(result.height == 1136) { 之前条件达到。

关于iPhone 或 iPhone 5 位置中的条件语句更新 : method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15068528/

相关文章:

iphone - 如何以编程方式比较 2 个音频文件?

ios - 按钮上的 Xcode 在单独的 ViewController 上按下隐藏标签

ios - NativeScript - Angular 2 自定义 AppDelegate

ios - 如果 Xcode 不再支持 armv6,你如何为 < iOS 4.3 构建/分发?

iphone - iPad 应用程序中奇怪的 UINavigationController 行为

c++ - 如何从 Windows 将闭路电视摄像头传输到 iPhone

iphone - clang 失败,退出代码为 1

ios - AFNetworking JSONRequestOperation

iphone - UISlider 拇指停止拖动

带有 python 套接字的 iPhone 客户端