-1

如何在从 tableview 中选择一行时打开 nib/xib/view... 下面是我的代码

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]);
    }
}
4

2 回答 2

0

只需将新的视图控制器添加为子视图。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NewViewController *myViewController = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
    [self.view addSubView:myViewController];
}
于 2013-02-19T03:35:55.347 回答
0

您应该使用 didSelectRowAtIndexPath 方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NewViewController *myViewController = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
[self presentModalViewController:myViewController animated:YES];
    }
于 2013-02-18T22:25:22.727 回答