2

UIAlertController でポップアップするアラートを取得しようとしていますが、次のエラーが発生し続けます。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <States: 0x17557b90>.'

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
}
4

1 に答える 1

8

UIAlertControllerは iOS 8 でのみ使用できます。以前のバージョンの場合は、古いコード パスを確認してフォールバックするか、非推奨の API を引き続き使用するか、幸せな小さなラッパー オブジェクトを作成する必要があります。

于 2014-10-20T16:03:36.183 に答える