我在 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条件码。它失败。该应用程序不会崩溃,而只会保留在视图控制器 (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,它也不起作用。
谢谢你的帮助