2011-12-01 94 views
1

我在我的应用程序中使用TableView,在弹出查看窗口时单击tabel单元格时,表格单元格中的所有内容都应显示在弹出窗口中在观看所以PLZ建议我该怎么办?如何在ipad中显示弹出窗口单元格中的tableview单元格

我有一些示例代码,下面哪个是不工作..所以建议与代码我希望单元格中的所有内容显示在弹出视图。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
UIView *aView = [[UIView alloc] init]; 
UIPopoverController *popoverController = [[UIPopoverController alloc] 
              initWithContentViewController:aView]; 
popoverController.popoverContentSize = CGSizeMake(320, 416); 
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
[popoverController presentPopoverFromRect:cell.bounds inView:cell.contentView 
       permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
} 

回答

4

UIPopoverController类引用明确指出

要显示酥料饼,创建该类的一个实例,并使用合适的方法中的一种呈现它 。初始化此类的实例 时,必须提供视图控制器,该视图控制器为弹出窗口提供 内容。 Popovers通常从它们的 视图控制器获得它们的大小

你的popoverController应该有一个视图控制器而不是一个视图。

YourViewController *aViewController = [[YourViewController alloc] initWithNibName:nibName bundle:nil]; 
UIPopoverController *popoverController = [[UIPopoverController alloc] 
              initWithContentViewController:aViewController]; 

然后你可以提出这个流行过

+0

THX了很多它的工作... – crazy2431

+0

@ 7KV7:+1伟大的答案..! :] –

+0

@ParthBhatt:谢谢。 – visakh7

1

你的代码是好的,但 你应该有UIViewController中,而不是UIView的。

-3

你要代替通过视图控制器的视图

+2

不是最好避免重复的答案,使网站更有效。请投票类似的答案,而不是重复 – visakh7

相关问题