IOS 代码创建控件,并有处理事件

IOS 代码创建控件,并有处理事件,第1张

概述IOS 代码创建控件,并有处理事件

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

    @interface AppDelegate()            @property UILabel* show;      @end            @implementation AppDelegate            - (BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions      {          self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];          // OverrIDe point for customization after application launch.          self.window.backgroundcolor = [UIcolor whitecolor];                    //创建一个UIVIEwController 对象          UIVIEwController* controller = [[UIVIEwController alloc] init];          //让该程序的窗口加载并显示 vIEwController 视图控制器关联的用户界面          self.window.rootVIEwController = controller;          //创建一个UIVIEw 对象          UIVIEw* rootVIEw = [[UIVIEw alloc] initWithFrame:[[UIScreen mainScreen] bounds]];          //设置 controller 显示 rootVIEw 控件          controller.vIEw = rootVIEw;          //创建一个圆角按钮          UIbutton* button = [UIbutton buttonWithType:UIbuttonTypeRoundedRect];          //设置按钮的大小          button.frame = CGRectMake(120,100,80,40);          //为按钮设置文本          [button setTitle:@"确定" forState:UIControlStatenormal];          //将按钮添加到 rootVIEw 控件中          [rootVIEw addSubvIEw:button];          //创建一个 UILabel 对象          self.show = [[UILabel alloc] initWithFrame:CGRectMake(60,40,180,30)];      //    UILabel* show = [[UILabel alloc] initWithFrame:CGRectMake(60,30)];          //将UILabel 添加到 rootVIEw 控件中          [rootVIEw addSubvIEw: self.show];          //设置 UILabel 默认显示的文本          self.show.text = @"初始文本";          self.show.backgroundcolor = [UIcolor graycolor];          //为圆角按钮的触碰事件绑定事件处理方法          [button addTarget:self action:@selector(clickHandler:) forControlEvents:UIControlEventtouchUpInsIDe];                    //将该 UIWindow 对象设为主窗口并显示出来          [self.window makeKeyAndVisible];          return YES;      }  

    - (voID)clickHandler:(ID)sender {          self.show.text = @"开始学习 IOS 吧!";      }  

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的IOS 代码创建控件,并有处理事件全部内容,希望文章能够帮你解决IOS 代码创建控件,并有处理事件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1232500.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存