gpt4 book ai didi

ios - NSInternalInconsistencyException : The specified modal presentation style doesn't have a corresponding presentation controller

转载 作者:行者123 更新时间:2023-12-01 15:54:52 30 4
gpt4 key购买 nike

更新到 iOS 8.0 SDK 后,我现在在尝试显示 UIImagePickerController 时遇到错误。来自 UITableViewCell :

*** Assertion failure in -[PartsSearchViewController 
_presentViewController:withAnimationController:completion:],
/SourceCache/UIKit/UIKit-3318.0.1/UIViewController.m:5726

*** Terminating app due to uncaught exception
'NSInternalInconsistencyException',
reason: 'The specified modal presentation style doesn't
have a corresponding presentation controller.'

我的 UITableViewCell “PartCell”声明如下:
@interface PartCell : UITableViewCell <UIImagePickerControllerDelegate>

PartCell 的 presentViewController 上失败了下面的行:
- (IBAction)takeAuditImageClicked:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = (id)self;
picker.allowsEditing = YES;
picker.modalPresentationStyle = UIModalPresentationNone;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

// FAILING ON THE LINE BELOW:
[[UIViewController topMostController] presentViewController:picker animated:YES completion:NULL];
}

这是来自 UIViewController 的代码生成单元格的“PartSearchViewController”:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"partCell";
UINib *nib = [UINib nibWithNibName:@"PartCell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:CellIdentifier];

PartCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];// forIndexPath:indexPath];
if (cell == nil)
{
cell = [[PartCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

}

[self fetchedResultsController:[self fetchedResultsControllerForTableView:tableView] configureCell:cell atIndexPath:indexPath];

return cell;
}

看完 UIViewControllerUIImagePickerController docs,我无法弄清楚代码现在失败的原因是什么。

最佳答案

问题在于

    picker.modalPresentationStyle = UIModalPresentationNone;

注释该行或将演示文稿样式选项更改为任何其他值都不会引发错误。

我猜 8.0 之前的 SDK 只是忽略了这个设置并默认为 UIModalPresentationFullScreen - 但这绝对是一个猜测。如果有人有更好的答案,我会相应地标记它!

来自苹果文档:

UIModalPresentationNone

A nonmodal view presentation or dismissal.

Available in iOS 7.0 and later.



(在 modalPresentationStyle 可用的七种演示样式选项中, UIModalPresentationNone 是唯一一个引发上述错误的选项。)

关于ios - NSInternalInconsistencyException : The specified modal presentation style doesn't have a corresponding presentation controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26392554/

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