我試圖得到一個警報,UIAlertController彈出,但我不斷收到此錯誤:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <States: 0x17557b90>.'
UIAlertController拋出NSInvalidArgumentException
if([InAppPurchaseVerifier hasSubscription]){
NSUInteger row = [indexPath row];
NSDictionary *myDict = [[NSDictionary alloc] initWithDictionary:[self.fullList objectAtIndex:row]];
NSString *state = [[NSString alloc] initWithString: [myDict objectForKey:@"0"]];
NSString *stateDetails = [[NSString alloc] initWithString: [myDict objectForKey:@"1"]];
OfficeInfo *anotherViewController = [[OfficeInfo alloc] initWithNibName:@"OfficeInfo" bundle:nil];
anotherViewController.stateName = state;
anotherViewController.stateDetails = stateDetails;
[state release];
[stateDetails release];
[self.navigationController pushViewController:anotherViewController animated:YES];
[anotherViewController release];
}else{
UIAlertController* alert = [[UIAlertController init] alertControllerWithTitle:@"Subscription Needed" message:@"You need to subscribe in order to access that. If you already have a subscription you may need to restore it" preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil]; // Error throws here
}
'UIAlertController'僅在iOS 8中可用。您是否可能嘗試在早期版本的操作系統上運行它? – 2014-10-20 15:53:32
是的,那一定是吧。我在我們的iOS 7設備上測試它...因此,舊的警報事件在8日貶值,但我們不得不使用它一段時間。很高興知道! – AndyD273 2014-10-20 15:59:42
是的,你有一個支票和分支。這是蹩腳的。你可以寫一個包裝器。 – 2014-10-20 16:03:01