zoukankan      html  css  js  c++  java
  • ios学习:页面跳转(present)

      1 //
      2 //  TWFXSecondViewController.m
      3 //  DemoMultiView
      4 //
      5 //  Created by Lion User on 12-12-24.
      6 //  Copyright (c) 2012年 Lion User. All rights reserved.
      7 //
      8 
      9 #import "TWFXSecondViewController.h"
     10 #import "TWFXThirdViewController.h"
     11 
     12 @interface TWFXSecondViewController ()
     13 
     14 @end
     15 
     16 @implementation TWFXSecondViewController
     17 @synthesize thirdViewController;
     18 
     19 
     20 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
     21 {
     22     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     23     if (self) {
     24         // Custom initialization
     25     }
     26     return self;
     27 }
     28 
     29 - (void)viewDidLoad
     30 {
     31     [super viewDidLoad];
     32     // Do any additional setup after loading the view from its nib.
     33 }
     34 
     35 - (void)didReceiveMemoryWarning
     36 {
     37     [super didReceiveMemoryWarning];
     38     // Dispose of any resources that can be recreated.
     39 }
     40 
     41 
     42 
     43 /*
     44  多视图切换,如果是从A视图跳转到B视图,那么A表示当前视图,B表示将要跳转到视图
     45  多视图跳转可以理解为有两部分:从A跳到B, B 返回 A.注意,是返回,不是重新发起跳转
     46  这里是第二阶段:从B返回A
     47  
     48  self.presentingViewController 在跳转发生后有效,表示B试图的上一个视图,在这里为A视图
     49  self.presentedViewController 在跳转发生后有效,表示B视图的下一个视图,在这里为nil,以为并没有发生跳转
     50  self.parentViewController表示B的父试图,也为nil
     51  */
     52 -(IBAction)btnClicGoBack:(UIButton *)sender{
     53     
     54     
     55     void(^task)() = ^{
     56         
     57         NSLog(@"2self: %@",self);
     58         NSLog(@"2back ed%@",self.presentedViewController);
     59         NSLog(@"2back ing%@",self.presentingViewController);
     60         //  NSLog(@"back par%@",self.parentViewController);
     61         printf("\n\n");
     62         
     63     };
     64     
     65    // task();
     66     
     67     //跳转完成后调用completion,此时,当前视图已被销毁,self.presentedViewController self.presentingViewController都为nil
     68     [self dismissViewControllerAnimated:YES completion:nil];
     69     
     70     task();//此时,当前视图还没被销毁,self.presentingViewController 表示上一个视图
     71 
     72 }
     73 
     74 - (IBAction)btnClickTraToFirst:(UIButton *)sender {
     75 }
     76 
     77 
     78 /*
     79  这里表示从B视图跳到C视图
     80  */
     81 - (IBAction)btnClickTra:(UIButton *)sender {
     82     
     83     if (self.thirdViewController == nil) {
     84         
     85         /*
     86          最常用的初始化方法
     87          nibName 表示xib文件的名字,不包括扩展名
     88          nibBundle 制定在那个文件束中搜索制定的nib文件,如在主目录下,则可以直接用nil
     89          */
     90         self.thirdViewController = [[[TWFXThirdViewController alloc] initWithNibName:@"TWFXThirdViewController" bundle:nil]autorelease] ;
     91         
     92     }
     93     
     94     //视图切换的动画效果
     95     self.thirdViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
     96     
     97     void(^task)() = ^{
     98         
     99         NSLog(@"2self: %@",self);
    100         NSLog(@"2go ed%@",self.presentedViewController);
    101         NSLog(@"2go ing%@",self.presentingViewController);
    102         //  NSLog(@"go par%@",self.parentViewController);
    103         printf("\n\n");
    104     };
    105     // task = ^(){};
    106     
    107     // task();//跳转前没意义
    108     
    109     
    110     /*
    111      completion是一个回调,当 当前视图(这里是TWFXViewController) 的viewDidDisear调用后,该回调被调用
    112      self.presentingViewController(表示上一个视图)为A视图
    113      self.presentedViewController(表示下一个试图)为C视图
    114      */
    115     [self presentViewController:thirdViewController animated:YES completion:task];
    116     
    117 
    118 }
    119 
    120 
    121 @end
  • 相关阅读:
    《白帽子讲web安全》学习笔记(第一篇)
    pytorch安装配置(VScode +miniconda+pytorch)
    tensorflow-GPU安装配置(VScode +miniconda+tensorflow-gpu)
    Win10+VScode +miniconda安装tensorflow(CPU版本)
    The TensorFlow library wasn't compiled to use SSE instructions解决方法
    python安装配置(miniconda版)(Win10+VScode +miniconda)
    Git使用方法
    PDF快速导出为word(免费方法)
    CAJ文件转PDF
    拖拽的效果 第一步 设置 可拖拽的属性 draggable="true" 绑定drag 事件 第二步 设置 放置位置 触发的事件 dragover 第三步 设置 放置之后 触发的事件 dragover 下面请看代码:
  • 原文地址:https://www.cnblogs.com/zouzf/p/2859480.html
Copyright © 2011-2022 走看看