gpt4 book ai didi

PopOver 中的 iOS TableViewController 在触摸 tableview 后消失

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

我正在开发通用 iOS 应用程序并尝试实现弹出窗口。我已经尝试过 WYPopoverController 和 FPPopover,但那两个也有同样的问题。

我有一个简单的 UITableViewController,它有 10 个单元格,在每个单元格上放置一个静态文本(仅用于测试)。

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

UILabel *label = (UILabel *) [cell viewWithTag:1];
[label setText:@"test"];

return cell;
}

并尝试在弹出窗口中显示它。

应用 FPPopover 的示例代码是

- (IBAction)test:(id)sender {
PopOverTableViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"PopOverTableViewController"];

FPPopoverController *popOver = [[FPPopoverController alloc] initWithViewController:vc];

[popOver presentPopoverFromView:sender];
}

这会在点击按钮时显示 10 个单元格中的文本,但是一旦我在 tableview 中滚动,文本消失,之后不调用 tableview 数据源方法。

它发生在 WYPopoverController 和 FPPopover 上,所以我假设我这边有问题。但是,我无法弄清楚哪里出错了。

非常感谢您对此提供的帮助。

最佳答案

谢谢大家回答我的问题。我自己解决了。这是由于 FPPopoverController 作为局部变量。我需要作为具有强属性的实例变量,否则 Controller 将被 ARC 释放。这使得弹出框仍然可见,但弹出框内的表格 View 内容被取消。

关于PopOver 中的 iOS TableViewController 在触摸 tableview 后消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19788624/

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