如何通过单击按钮打开.xib

时间:2011-05-27 00:22:45

标签: iphone objective-c cocoa-touch ios4

任何人都可以告诉我如何从UIButton打开一个新的.xib?我的意思是,如果我点击一个按钮,它将打开一个新窗口。

2 个答案:

答案 0 :(得分:4)

将按钮的内部触摸事件链接到UIViewController子类中的IBAction方法。在该方法中,使用:

使用xib实例化一个新的UIViewController
YourViewControllerClass *vc= [[YourViewControllerClass alloc] initWithNibName:@"YourXibName" bundle:nil];

然后,如果你有一个导航控制器,你想把它推到:

[self.navigationController pushViewController:vc animated:YES];
[vc release];

答案 1 :(得分:0)

NewTableController *newTableController=[[NewTableController alloc] initWithNibName:@"NewTableController" bundle:nil];
    [self.navigationController pushViewController:newTableController animated:YES];