zoukankan      html  css  js  c++  java
  • UI 指派初始化方法 视图控制器 button响应方法

     1 #import "MainViewController.h"
     2 
     3 @interface MainViewController ()
     4 // 延展 :管理类私有的属性和方法
     5 @end
     6 
     7 @implementation MainViewController
     8 // 指派初始化方法
     9 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    10 {
    11     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    12     if (self) {
    13         // Custom initialization
    14         // 数据的处理 在初始化方法中写
    15     }
    16     return self;
    17 }
    18 // 视图结束加载
    19 // viewController自带的view加载完毕时候调用
    20 - (void)viewDidLoad
    21 {
    22     [super viewDidLoad];
    23     // Do any additional setup after loading the view.
    24     // 一般的试图操作(添加视图 改变视图设置)都在这个方法中
    25     self.view.backgroundColor = [UIColor redColor];
    26     
    27     UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    28     button.frame = CGRectMake(20, 120, 280, 30);
    29     [button setTitle:@"点 击" forState:UIControlStateNormal];
    30     [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    31     [self.view addSubview:button];
    32     NSLog(@"%s", __FUNCTION__);
    33 
    34 }
    35 
    36 
    37 // button响应方法
    38 - (void)buttonClicked:(UIButton *)button
    39 {
    40     // 弹出新的视图控制器
    41     // 1.创建第二个试图控制器
    42     SecondViewController *secondVC = [[SecondViewController alloc] init];
    43     // 2.弹出
    44     // 参数1:需要弹出的viewController
    45     // 参数2:是否需要动画
    46     // 参数3:弹出执行完毕后 执行块(Block)里的代码
    47     [self presentViewController:secondVC animated:YES completion:^{
    48         // code
    49     }];
    50     [secondVC release];
    51 }
    52 // viewController生命周期 方法
    53 // 视图view已经出现
    54 -(void)viewDidAppear:(BOOL)animated
    55 {
    56     [super viewDidAppear:animated];
    57     NSLog(@"%s", __FUNCTION__);
    58 }
    59 -(void)viewWillAppear:(BOOL)animated
    60 {
    61     [super viewWillAppear:animated];
    62     NSLog(@"%s", __FUNCTION__);
    63 }
    64 -(void)viewWillDisappear:(BOOL)animated
    65 {
    66     [super viewWillDisappear:animated];
    67     NSLog(@"%s", __FUNCTION__);
    68 }
    69 -(void)viewDidDisappear:(BOOL)animated
    70 {
    71     [super viewDidDisappear:animated];
    72     NSLog(@"%s", __FUNCTION__);
    73 }
    74 // 收到内存警告的时候 会调用这个方法
    75 - (void)didReceiveMemoryWarning
    76 {
    77     [super didReceiveMemoryWarning];
    78     // Dispose of any resources that can be recreated.
    79     NSLog(@"%s", __FUNCTION__);
    80 }
    81 
    82 /*
    83 #pragma mark - Navigation
    84 
    85 // In a storyboard-based application, you will often want to do a little preparation before navigation
    86 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    87 {
    88     // Get the new view controller using [segue destinationViewController].
    89     // Pass the selected object to the new view controller.
    90 }
    91 */
    92 
    93 @end
    有人说:爱上一座城,是因为城里住着某个人,能够与所爱的人在一起,连光阴都是美的。即便粗茶淡饭,修篱种田,只要有你陪伴就好。那么,找一个青山绿水的地方,寻一处幽静的茅舍,或是云水禅心的庭院,那里有晴朗的阳光和静谧的悠然,还有你明媚的笑脸。掬一捧花香在平淡的日子,握着一路相随的暖意,让爱的馨香在柴米油盐中升腾;在一杯茶的温情里,体味生活的诗意;在一碗粥的清淡中,感受生活的浪漫,每天清晨你和阳光都在,便是我的幸福。——春暖花开 《择一城终老,遇一人白首》
  • 相关阅读:
    国标ikecin插座资料
    LED平面管测试资料
    elementui使用MessageBox 弹框自定义内容$msgbox:实现一个textarea文本输入框
    ajax请求的时候后台有三个服务器地址
    前端用xshell向后端服务器部署项目
    vue+echarts 实现map3D地图tooltip弹框读取后台返回的数据,并显示弹框
    AWS网络架构及知识概述
    K8s控制器 StatefulSet
    pod的数据持久化2 NFS
    Pod的数据持久化1 hostPath 和emptyDir
  • 原文地址:https://www.cnblogs.com/-Eric-Liu/p/5563936.html
Copyright © 2011-2022 走看看