2013-01-03 46 views
2

我有一个表格视图,当用户选择一个特定的行时,我想显示一个简单的操作表来选择新的条目是来自现有的联系人,还是创建一个新的联系人。我显示该动作片作为这样:UIActionSheet不显示在弹出窗口

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.row != 0 ) 
    { 
     //Select the entry 
    } 
    else 
    { 
     UITableViewCell *selectedRow = [tableView cellForRowAtIndexPath:indexPath]; 
     UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"New Contact", @"Existing Contact", nil]; 

     [sheet showFromRect:selectedRow.frame inView:tableView animated:YES]; 
     return; 
    } 

    //Do some other stuff... 

}

根据文档...

讨论

在iPad上,这种方法显示的操作片在酥料饼 其箭头指向视图的指定矩形。弹出框 不与指定的矩形重叠。

然而...行动表显示在我的视图的底部,而不是弹出到一边。 tableview是一个splitviewcontroller中的主视图

任何想法为什么这不起作用?

回答

0

而不是从的tableView大跌眼镜,尝试转换单元边界到最视图(控制器,并从那里弹出它...

CGRect frame = [self.view convertRect:cell.bounds fromView:cell]; 
[sheet showFromRect:frame inView:self.view animated:YES]; 

可能是,还有的的tableView内更多层次的情况和它打破你的东西

+0

试过这个:'CGRect frame = [selectedRow convertRect:selectedRow.frame toView:self.view]; [sheet showFromRect:frame inView:self.view animated:YES];'虽然没有用,但同样的确切行为 –

1

我有同样的问题,这个答案来帮助我。

Using UIActionSheet on iPad

如果你从一个的UIBarButtonItem或UIToolbar 是已经 一个酥料饼它,然后以类似的方式展现为在 iPhone

事情是对我的内心表现出来,该表显示为分割视图,并且在横向上显示该表格是作为弹出窗口显示的(横向面板,您可以通过轻扫进行隐藏),因此,一旦将设备转为横向模式,UIActionSheet就会在弹出窗口中显示。原因是我大胆的:它不能在另一个popover中显示为popover。