【问题标题】:iOS - UITableView with custom frame and custom cell to display UIPopOver from itiOS - 带有自定义框架和自定义单元格的 UITableView 以从中显示 UIPopOver
【发布时间】:2012-09-17 20:51:03
【问题描述】:

我的问题分为两部分:

第 1 部分:

我有一个有 4 行的UITableView,当用户单击任何单元格时,它将显示一个内部UITableView,我已经扩展了主UITableView 的大小,然后插入内部@ 987654325@

internalTableView = [[InternalApartmentTableViewController alloc] initWithFrame:CGRectMake(0, 44, 550, (([[tableContent objectAtIndex:indexPath.row] count] - 1) * 44))];
[cell addSubview:internalTableView];

didSelectedRow 是:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (selectedInternal != -1) {
    selectedInternal = -1;
} else {
    selectedInternal = indexPath.row;
    [internalTableView removeFromSuperview];
    [internalTableView release];
}
[tableViews reloadData];

}

我正在使用内部UITableView 的少量行测试应用程序,高度 = 700 并且一切正常,在我使用真实数据时,高度 = 2500 和显示数据之间,高度出现在 = 1000 左右,我不需要内部 UITableView 可滚动,只需主 UITableView 可滚动。

那么,我怎样才能将UTableView 的帧尺寸扩大到我想要的程度?

第 2 部分:

在内部 UITableView 中,我使用了一个自定义单元格,其中包含标签和图像以及 2 个按钮,其中一个按钮被点击时,我想从它的位置显示一个 UIPopOver,我不能确定按钮在视图中的位置,实际上,我不知道应该使用哪个视图在屏幕上显示UIPopOver

[popoverController presentPopoverFromRect: //(How can i get the rect for the button)
                   inView: //(in which view should the PopOver appear, master UITableView or Internal UITableView or Custom Cell)
                   permittedArrowDirections:UIPopoverArrowDirectionLeft
                   animated:YES];

我们将不胜感激。

【问题讨论】:

  • 将一个表格视图嵌入另一个表格视图听起来很麻烦。 Apple 对处理此类案例的建议(在去年 WWDC 的一些 sample code 中有所介绍)是添加更多行……您可能会发现这更容易。
  • +1 给你@rickster,那么问题的第 1 部分就解决了(原则上),那么第 2 部分呢?
  • 嗯,不再有内部表格视图,所以弹出框不会从那里出现。 :) 可能(以前的外部)表格视图是您想要的。

标签: ipad uitableview custom-cell uipopover


【解决方案1】:

//自定义单元格的btn按下时

if(![tempPopover isPopoverVisible])
{

    UIButton* btn=(UIButton *)sender;
    NSIndexPath*indexpath=[NSIndexPath indexPathForRow:btn.tag inSection:0];
    cell=(customCell *)[tableView cellForRowAtIndexPath:indexpath];

        popoverController *objView = [[popoverController alloc] init];

        tempPopover = [[UIPopoverController alloc] initWithContentViewController:objView];
        [tempPopover setPopoverContentSize:CGSizeMake(160, 160)];
        [tempPopover presentPopoverFromRect:CGRectMake(655, cell.contentView.frame.origin.y-105, 150, 150) inView:cell.contentView permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多