gpt4 book ai didi

iphone - 呈现 UIPopoverviewcontroller

转载 作者:行者123 更新时间:2023-11-29 03:53:59 26 4
gpt4 key购买 nike

我正在开发一个使用UIPopoverController的应用程序,我在呈现该弹出窗口时遇到问题,我有一个添加在self.view上的UIView,并在该 View 上添加了一个表格 View ,该表格 View 有一个自定义单元格,其中包括一个 UITextField,在 didBeganEditing 方法上我需要打开弹出窗口。

这是代码:

   table = [[UITableView alloc]initWithFrame:CGRectMake(textField.frame.origin.x,textField.frame.origin.y,200,100) style:UITableViewStylePlain];

table.tag=3;
[table setDataSource:self];
[table setDelegate:self];
[table reloadData];
UITableViewController *tableViewController= [[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped];
tableViewController.tableView = table;

popOver= [[UIPopoverController alloc]
initWithContentViewController:tableViewController];

[popOver presentPopoverFromRect:popRect inView:cell permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

我将收到以下异常

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.'

最佳答案

这里你在单元格中呈现popoverview,并将矩形赋予UITableViewController的popover,所以你会得到这个错误..这里它没有 View 层次结构,所以它没有获取窗口并在这里崩溃,只需按照查看层次结构。

关于iphone - 呈现 UIPopoverviewcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16733717/

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