【发布时间】:2013-05-21 01:19:04
【问题描述】:
我很难从 tableviewCell 的附件按钮正确显示弹出框。
我不使用附件视图的原因是单元格处于编辑模式,我无法同时显示绿色加号 + 自定义附件视图。也许我忽略了前面的某些内容?
目前我的弹出框显示正确,但这只是这种配置的情况,因为我设置了与原点的静态距离......有什么想法可以解决这个问题吗?
代码:
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
if (![self duplicateDayContent]) {
duplicateDayContent = [[self storyboard]instantiateViewControllerWithIdentifier:@"CopyDay"];
[duplicateDayContent setDelegate:self];
duplicateDayPopover = [[UIPopoverController alloc]initWithContentViewController:duplicateDayContent];
duplicateDayPopover.popoverContentSize = CGSizeMake(320, 600);
}
CGRect rect = CGRectMake(cell.bounds.origin.x+800, cell.bounds.origin.y+10, 50, 30);
[duplicateDayPopover presentPopoverFromRect:rect inView:cell permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
}
【问题讨论】:
-
可能你会考虑 cell.accessoryView.bounds 或直接考虑 cell.accessoryView.frame
-
非常感谢您的建议。我试过: CGRect rect = CGRectMake(cell.accessoryView.bounds.origin.x, cell.accessoryView.bounds.origin.y, 50, 30);但这在 x 方面不起作用。也许是因为我实际上并没有加载附件视图?还是我错过了什么?
-
cell.accessoryView.bounds.size.width-50 尝试在 CGRectMake 第一个参数中使用这个
-
再次感谢您的建议 tirupathi,没有解决。瑞秋的提示帮助了我,谢谢!!我以某种方式认为附件视图无效,因为我使用了附件类型。吸取教训!
标签: ios ipad popover cgrect uitableview