Neil的备忘录

just do it
posts - 66, comments - 8, trackbacks - 0, articles - 0

Iphone 不同页面间跳转

Posted on 2010-10-06 16:34 Neil's NoteBook 阅读(1640) 评论(1)  编辑  收藏 所属分类: Iphone Development
1. 创建一个新的viewcontroller,比如 NewOrderViewController,同时创建实现文件和头文件
2. 创建一个view,比如 NewOrderView.xib
3. 双击打开NewOrderView.xib,指定其class为 NewOrderViewController,并在 Interface Builder中将view与File Owner连接起来
4. 在RootViewController.h文件中定义 NewOrderViewController, 设置其为属性,代码如下:

@class NewOrderViewController;

@interface RootViewController : UITableViewController {

NewOrderViewController *newOrderViewController;

}

@property (nonatomic, retain) NewOrderViewController *newOrderViewController;

5. 在RootViewController.m文件中实现跳转,代码如下:
//添加按钮

- (void)viewDidLoad {

    [super viewDidLoad];


    self.navigationItem.title = @"订单列表";

    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

    UIBarButtonItem *buttonEdit = [[[UIBarButtonItem alloc] initWithTitle:@"编辑" style:UIBarButtonItemStyleBordered target:self            action:@selector(editCharacters)] autorelease];

    UIBarButtonItem *buttonAdd = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showNewOrderView)] autorelease];

    self.navigationItem.leftBarButtonItem=buttonEdit;

    self.navigationItem.rightBarButtonItem=buttonAdd;

//实现跳转

- (void) showNewOrderView {

    if (self.newOrderViewController == nil) {

        NewOrderViewController *newOrder = [[NewOrderViewController alloc] initWithNibName:@"NewOrderView" bundle:nil];

        self.newOrderViewController = newOrder;

        [newOrder release];

    }

    [self.navigationController pushViewController:self.newOrderViewController animated:YES];

Feedback

# re: Iphone 不同页面间跳转[未登录]  回复  更多评论   

2012-02-13 10:42 by ameng
谢谢,对我很有用

只有注册用户登录后才能发表评论。


网站导航: