2011-12-01 91 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

相關問題