你好,歡迎來到IOS教程網

 Ios教程網 >> IOS訊息 >> 關於IOS >> iPhone不同頁面之間跳轉

iPhone不同頁面之間跳轉

編輯:關於IOS

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];

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved