iOS三種頁面跳轉方法
阿新 • • 發佈:2018-12-24
// 第一種通過給頁面設定tag值 // 把tag值為3000的view帶到最前面 也就是顯示在螢幕上; [self.window bringSubviewToFront:[self.window viewWithTag:3000]]; // 把tag值為2000的view送到最後, 讓他下面的view顯示 [self.window sendSubviewToBack:[self.window viewWithTag:2000]]; /**************************************華麗分割線********************************************/ // 第二種 模態跳轉 - (void)isClick:(UIButton *)button { // 模態跳轉 // 1. 建立目標頁面的物件 SecondViewController *secVC = [[SecondViewController alloc]init]; // 2. 設定跳轉的動畫樣式 secVC.modalTransitionStyle = 0; // 3. 向目標頁面進行跳轉 [self presentViewController:secVC animated:YES completion:^{ }]; // 4. 記憶體管理 [secVC release]; } - (void)isCilck:(UIButton *)button { // 返回前一頁面 [self dismissViewControllerAnimated:YES completion:^{ }]; } /**************************************華麗分割線********************************************/ // 第三種 導航控制器跳轉 - (void)buttonAction:(UIButton *)button { // 1. 先建立目標頁面物件 SecondViewController *secVC = [[SecondViewController alloc]init]; // 2. 跳轉 [self.navigationController pushViewController:secVC animated:YES]; // 3. 記憶體管理 [secVC release]; } - (void)buttonAction:(UIButton *)button { ThirdViewController *third = [[ThirdViewController alloc]init]; [self.navigationController pushViewController:third animated:YES]; }