iOS開發 跳轉情境的三種方式

來源:互聯網
上載者:User

標籤:style   http   io   os   ar   for   檔案   div   sp   

iOS開發 跳轉情境的三種方式2012年10月17日, 15:32

假設A跳轉到B,三種方法:
1.按住ctrl鍵,拖動A上的控制項(比如說UIButton)到B上,快顯功能表,選擇Modal.不需要寫任何代碼,在A上點擊Button就會跳轉到B
2. 按住ctrl鍵,拖動A上的View Controller到B上,快顯功能表,選擇Modal,兩個情境間自動添加連接線和表徵圖,選中該表徵圖,開啟Storyboard Segue,identifier輸入一個標識符,這裡以”aaaa”為例.A裡需要跳轉時,執行下面的代碼:

1
 [self performSegueWithIdentifier:@"aaaa" sender:self];

3.完全用代碼來實現,代碼如下:

123456789
    //先擷取UIStoryBoard對象,參數為檔案名稱    UIStoryboard *mainStoryBoard=[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];    //擷取SecondViewController執行個體,參數是StoryBoard ID,選中View Controller,在Identity Inspector中    SecondViewController *second=[mainStoryBoard instantiateViewControllerWithIdentifier:@"second"];    //設定過渡的樣式,和顯示的樣式    second.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;    second.modalPresentationStyle=UIModalPresentationFormSheet;    //顯示    [self presentViewController:second animated:YES completion:nil];

iOS開發 跳轉情境的三種方式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.