2013-02-18 93 views
-1

的細胞點擊我如何打開一個筆尖/ XIB /視圖,而從我的tableview選擇行...下面是我的代碼負載筆尖在的tableview

public class TableViewDelegate : UITableViewDelegate 
{ 
    private List list; 

    public TableViewDelegate(List<string> list) 
    { 
     this.list = list; 
    }  

    public override void RowSelected (UITableView tableView, NSIndexPath indexPath) 
    { 
     Console.WriteLine("TableViewDelegate.RowSelected: Label={0}",list[indexPath.Row]); 
    } 
} 

回答

0

/XIB /視圖,您應該使用didSelectRowAtIndexPath方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NewViewController *myViewController = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil]; 
[self presentModalViewController:myViewController animated:YES]; 
    } 
+0

不應該有一個navigationController,只是在它創建一個類? – user2084736 2013-02-18 23:13:24

+0

實際上,您可以以模態方式呈現視圖控制器 - 如果您不使用UINavigationBar,可能會更有意義。 – TiernanKennedy 2013-02-19 15:47:17

+0

查看更新代碼 – TiernanKennedy 2013-02-19 15:48:17

0

只需將新視圖控制器作爲子視圖添加即可。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NewViewController *myViewController = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil]; 
    [self.view addSubView:myViewController]; 
} 
+0

我不能加載任何的筆尖,以便你們試圖教我。 – user2084736 2013-02-19 17:00:41