我在locationUpdate:method中有这个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,它也不起作用。
感谢您的帮助
答案 0 :(得分:0)
刚想通了。我有}
在if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
条件到达之前关闭了if(result.height == 1136) {
。