gpt4 book ai didi

ios - UIAlertController 抛出 NSInvalidArgumentException

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:01:39 25 4
gpt4 key购买 nike

我正在尝试使用 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
}

最佳答案

UIAlertController 仅在 iOS 8 中可用。对于以前的版本,您必须检查并回退到旧代码路径,继续使用已弃用的 API,或者编写一个快乐的小包装器对象。

关于ios - UIAlertController 抛出 NSInvalidArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26469241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com