UITableViewcell 中的 Popover 不会立即出现. [英] Popover in UITableViewcell not coming immediately .

查看:20
本文介绍了UITableViewcell 中的 Popover 不会立即出现.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态的 tableviewcontroller SideBarTableViewController.m/.h .
有一个弹出视图控制器 - popUpViewController.m/.h已将 SideBarTableViewController -> RegisterTableViewCell.m/.h 的单元格子类化,并从单元格向其添加了一个按钮出口.已使用present As popover"segue 将单元格连接到情节提要中的 popUpViewController,并且 segue 被赋予标识符popover".故事板中的锚点目前已设置为 Tableview,稍后在 preparesegue 中进行更改.

i have a dynamic tableviewcontroller SideBarTableViewController.m/.h .
Have a pop up view controller - popUpViewController.m/.h Have subclassed a cell of SideBarTableViewController -> RegisterTableViewCell.m/.h and added a button outlet from the cell to it. Have connected the cell to popUpViewController in storyboard using "present As popover" segue and the segue is given identifier "popover". The anchor point in storyboard has been set to Tableview for now , changing it later in preparesegue .

注册TableViewCell.h

RegisterTableViewCell.h

@property (weak, nonatomic) IBOutlet UIButton *PopoverAnchorButton; 

SideBarTableViewController.m

SideBarTableViewController.m

#import "RegisterTableViewCell.h"
 (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

if([segue.identifier isEqualToString:@"popover"] && segue.destinationViewController.popoverPresentationController){
    UIPopoverPresentationController *popController = segue.destinationViewController.popoverPresentationController;
    popController.sourceView = sender;
    RegisterTableViewCell *cell = [[RegisterTableViewCell alloc]init];
 segue.destinationViewController.popoverPresentationController.sourceRect = CGRectMake(cell.PopoverAnchorButton.frame.size.width/2, cell.PopoverAnchorButton.frame.size.height, 0, 0);
    popController.delegate = self;
    } 
}



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

NSString *cellIdentifier = [menuItems objectAtIndex:indexPath.row];

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];



RegisterTableViewCell *regcell = [[RegisterTableViewCell alloc]init];

[regcell.PopoverAnchorButton addTarget:self action:@selector(PresentPopover:) forControlEvents:UIControlEventTouchUpInside];

// Configure the cell...



return cell;

}

-(void) PresentPopover:(UIButton *)sender

{

NSLog(@"present popover called ");

[self performSegueWithIdentifier:@"popover" sender:sender];

}

popUpViewController.m

popUpViewController.m

- (IBAction)closeview:(id)sender {

[self.view removeFromSuperview];

}

问题:

弹出窗口从单元格的左端显示,但是我看到了,弹出窗口显示有延迟.通常情况下,首先单击单元格,弹出窗口如预期,
第二次点击 -> 小延迟,
第三 -> 多一点延迟......(延迟并不总是增加,但固定 6-7 秒)

The popup is displayed from the left end of the cell, but wat i see , there is a delay in popup presentation . Normally , first click in the cell, popup comes up as expected ,
second click -> little delay ,
third -> little more delay ... (delay not always increasing though, but fixed 6-7 seconds )

让 ipad 闲置 6 秒,然后再次单击单元格,弹出窗口立即显示.

let the ipad be idle for say 6 seconds , and again click in the cell, popup shows immediately .

在单元格中双击(2 次点击)会立即显示它,但带有警告:

double clicking(2 taps ) in the cell displays it immediately but with a warning :

2016-07-11 22:53:05.462 Player-app_03[1947:590814] Warning: Attempt to present <UINavigationController: 0x125026400>  on <SideBarTableViewController: 0x124d258f0> which is already presenting (null)

这里发生了什么?我一无所知.任何人请帮忙.

What is happening here ? i am clueless. Anybody please help.

推荐答案

问题很可能出在 segue.destinationViewController 的动作中,从 OP 代码来看,它本身似乎是处理另一个视图控制器.要对此进行处理,请省略您拥有的 prepareForSegue 逻辑,并省略目标 vc 的 viewDidLoadviewWillAppear 中与以下内容相关的任何内容vc 演示文稿.

The problem is likely to be found in the actions of the segue.destinationViewController, which, from the OP code, appears itself to handle another view controller. To get a handle on this, omit the prepareForSegue logic that you have, and omit anything in the destination vc's viewDidLoad or viewWillAppear that is related to vc presentation.

segue.destinationViewController 是将要呈现的视图控制器.任何与此相关的事情都是自找麻烦.

The segue.destinationViewController is the view controller that's going to get presented. Anything that messes with that is asking for trouble.

延迟时间的增加很可能是由 closeview 中的动作(而不是不动作)引起的,它只是移除了弹出视图控制器的视图,而无限期地留下视图控制器本身.该方法中的正确操作是调用:

The increasing lag time is very likely caused by the action (inaction, rather) in closeview, which is merely removing the popup view controller's view, leaving the view controller itself around indefinitely. The proper action in that method is to call:

[self dismissViewControllerAnimated:YES completion:nil];

另外,请注意,您直接分配表格视图单元格的任何地方(在 OP 代码中进行了两次),至少表明存在误解,甚至可能是错误.

Also, please note that any place you directly allocate a table view cell (done twice in the OP code), is indicative of at least a misunderstanding, and probably a mistake.

这篇关于UITableViewcell 中的 Popover 不会立即出现.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆