UI 常用方法總結之--- UIViewController UIResponder

UIViewController : UIResponder <NSCoding, UIAppearanceContainer, UITraitEnvironment, UIContentContainer>

 

關於UIViewController生命週期

loadView -> viewDidLoad -> viewWillAppear -> viewDidAppear -> viewWillDisappear -> viewDidDisappear

 

 

模態推出Modal

執行跳轉

    //模態推出Modal

    //推出一個新的頁面(viewController)

    //1.創建新的頁面

    VisionSecondViewController *secondVC = [[VisionSecondViewController alloc]init];

    //設置推出動畫

    [secondVC setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];

    //2. 推出

    //參數1: 要推出的新視圖控制器(viewController)

    //參數2: 是不是帶一個動畫效果

    //參數3:

    [self presentViewController:secondVC animated:YES completion:^{

        //推出新視圖之後,要執行的代碼

    }];

    

    //3.內存管理

    [secondVC release];

 

跳轉回執行目標

 

 [self dismissViewControllerAnimated:YES completion:^{

        //

    }];

 

 

UIResponder : NSObject

 

UIImageView 和 UILable 默認關閉交互

需要打開 打開方法:

self.imageView.userInteractionEnabled = YES;

觸摸事件

 

1.- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

 

2.- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

 

3.- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

 

4.- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

 

UITouch *touch = [touches anyObject];

 

 

搖晃事件

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);

 

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);

 

- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章