无法在使用Objective C的iOS中使用UIPoverPresentationController_passthroughViews方法导航到控制器

68de4m5k  于 2023-05-19  发布在  iOS
关注(0)|答案(1)|浏览(197)

无法在使用Objective C的iOS中使用UIPoverPresentationController_passthroughViews方法导航到控制器。
我正在尝试使用UIPopoverPresentationController的passthroughView导航到控制器视图。但我无法设置此导航,并得到一个错误和应用程序被崩溃。我该如何解决这个问题?
在这里,我还面临着一个错误,弹出窗口中的最后一个项目显示为页脚或不可移动的标签,如果我点击这个,没有突出显示,代码:

SelectorViewController* sv = [[SelectorViewController alloc] initWithStyle:UITableViewStylePlain];
sv.delegate = self;
sv.currentTopic = self.title;
NSLog(@" sv.currentTopic%@", sv.currentTopic);
sv.preferredContentSize = CGSizeMake(300, 500);
sv.modalPresentationStyle = UIModalPresentationPopover;
        
UIPopoverPresentationController *popoverpresentationController = sv.popoverPresentationController;
popoverpresentationController.delegate = self;
popoverpresentationController.sourceView = sender.view;
 [self present view controller:sv animated: YES completion: nil];  
   popover.delegate = self;
   if ([popover respondsToSelector:@selector(setBackgroundColor:)])
         popover.backgroundColor = [UIColor whiteColor];
         [sv release];
ni65a41a

ni65a41a1#

看起来您试图从视图控制器呈现弹出框,并将passthroughViews设置为导航控制器的委托。UIPopoverPresentationControllerpassthroughViews属性是一个视图数组。
正确的用法应该是:

// Assuming `view1` and `view2` are views that you want the user to interact with while the popover is visible
popoverpresentationController.passthroughViews = @[view1, view2];

如果您想在弹出框出现时导航到另一个控制器,可以在弹出框的delegate方法popoverPresentationControllerDidDismissPopover中完成。
至于无法与内容交互的问题,请确保弹出框的preferredContentSize足够大,可以完全显示tableview及其单元格。另外,检查tableview的contentSize

相关问题