【发布时间】:2012-05-16 23:42:41
【问题描述】:
我有一个 UIViewController,我有一个导航栏和一个表格,现在我想在选择表格行时从这个视图导航到另一个视图。
我该怎么做?
【问题讨论】:
标签: iphone ipad uinavigationcontroller uitableview
我有一个 UIViewController,我有一个导航栏和一个表格,现在我想在选择表格行时从这个视图导航到另一个视图。
我该怎么做?
【问题讨论】:
标签: iphone ipad uinavigationcontroller uitableview
首先将新的 UIViewController 添加到您的应用程序中,方法是右键单击文件和组部分并单击“New File”选项并将其命名为 SecondViewController。
确保在创建 SecondViewController 时选择“With XIB for user interface”选项添加一个 XIB
假设您想在按钮单击时推送新视图,然后向 FirstViewController 添加一个按钮,并在其按钮的 TouchUpInside 事件中添加以下代码:
SecondViewController *secondView=[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondView animated:YES];
[secondView release];
如果您使用的是 ARC,请删除 [secondView release];。
如果您需要更多帮助,请告诉我。
希望这会有所帮助。
【讨论】:
FileName *file=[[FileName alloc] initWithNibName:@"FileName.xib" bundle:nil];
[self.navigationController pushViewController:file animated:YES];
[file release];
【讨论】: