问题描述
我正在开发通用的iOS应用,并尝试实现弹出窗口.我已经尝试过WYPopoverController和FPPopover,但是那两个也有同样的问题.
I am developing universal iOS app and try to achieve popover.I have tried WYPopoverController and FPPopover but those 2 does the same issue.
我有一个简单的UITableViewController,其中有10个单元格,在每个单元格上放置一个静态文本(仅用于测试).
I have simple UITableViewController having 10 cells putting a static text on each cell (just for a test).
#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;
}
并尝试在弹出窗口中显示.
and try to show this in popover.
应用FPPopover的示例代码为
Sample code to apply FPPopover is
- (IBAction)test:(id)sender {
PopOverTableViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"PopOverTableViewController"];
FPPopoverController *popOver = [[FPPopoverController alloc] initWithViewController:vc];
[popOver presentPopoverFromView:sender];
}
这会在一个按钮上显示10个单元格中的文本,但是一旦我在表格视图中滚动,文本消失,随后将调用非tableview数据源方法.
This shows text in 10 cells at a button tap but once I scroll inside of tableview,the texts disappear and non of tableview data source methods are called afterwards.
WYPopoverController和FPPopover都发生了,所以我假设我这边出了问题.但是,我无法弄清楚哪里出了问题.
It happened for both WYPopoverController and FPPopover so I am assuming there is something wrong in my side.However, I could not figure out where I went wrong.
感谢您在此方面的帮助.
I appreciate your help on this.
推荐答案
谢谢你们回答我的问题.我解决了自己.这是由于在局部变量中有FPPopoverController.我需要将具有强大属性的实例变量放入,否则控制器将由ARC释放.使得弹出框仍然可见,但是弹出框内的表视图内容被忽略了.
Thank you guys for answering my question.I solved myself. It was due to having FPPopoverController as in local variable. I needed to put as instance variable with strong property, otherwise the controller is deallocated by ARC. That made a popover frame is still visible but table view content inside of popover is dismissed.
这篇关于触摸tableview后,PopOver中的iOS TableViewController消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!