[XCode] 通过Assistant Editor完成拖拽映射UI元素和Action
2015-06-26 16:29
645 查看
参考:http://www.tutorialspoint.com/ios/ios_actions_and_outlets.htm
【目标】
类似Visual Studio | MFC的Class Wizard生成UI元素和代码中对象的映射,以及点击一个button就自动生成相应的响应函数的代码一样,我们希望在XCode中也有类似的功能。
【做法举例】
1)打开storyboard,在其中添加一个button和一个label
2)选择 View -> Assistant Editor -> Show Assistant Editor,这样,在storyboard的右边出现了另一个编辑区,即所谓的Assistant Editor区域
3)在右边的Assistant Editor区域打开ViewController.h
4)在ViewController.h中,在默认生成的ViewControler类定义后面加上{}
5)在storyboard中右击Label元素,然后拖拽到4)添加的{}中间,在弹出的对话框中填入变量名,比如myTitleLabel,确定后,就生成了IBOutlet UILable *myTitleLable变量,它和界面中的Label元素是一一对应的
详细例子,见 http://www.tutorialspoint.com/ios/ios_actions_and_outlets.htm
【目标】
类似Visual Studio | MFC的Class Wizard生成UI元素和代码中对象的映射,以及点击一个button就自动生成相应的响应函数的代码一样,我们希望在XCode中也有类似的功能。
【做法举例】
1)打开storyboard,在其中添加一个button和一个label
2)选择 View -> Assistant Editor -> Show Assistant Editor,这样,在storyboard的右边出现了另一个编辑区,即所谓的Assistant Editor区域
3)在右边的Assistant Editor区域打开ViewController.h
4)在ViewController.h中,在默认生成的ViewControler类定义后面加上{}
5)在storyboard中右击Label元素,然后拖拽到4)添加的{}中间,在弹出的对话框中填入变量名,比如myTitleLabel,确定后,就生成了IBOutlet UILable *myTitleLable变量,它和界面中的Label元素是一一对应的
详细例子,见 http://www.tutorialspoint.com/ios/ios_actions_and_outlets.htm
相关文章推荐
- 直接拿来用!10款实用Android UI工具
- AlertDialog.Builder(各种对话框实现)
- druid连接池配置
- 《GK101任意波发生器》升级固件发布(版本:1.0.2build851)
- !!!继承UILabel, iOS8.0 不会调用 (void)layoutSubviews
- [SoapUI] 通过SoapUI发送POST请求,请求的body是JSON格式的数据
- Android UI性能优化实战 识别绘制中的性能问题
- 《Java程序设计》第16周周四:GUI编程及文件对话框的使用
- UEditor 1.4.2+版本文件图片上传路径配置
- Android requires compiler compliance level 5.0 or 6.0. Found '1.8' instead. Please use Android Tools>Fix project Properties.
- druid简介
- jquer ajax
- Gradle finished with non-zero exit value 1 ic_launcher.png: Original is here. The version qualifie
- setuid和setgid
- UIPickerView的方法和属性
- 50个UI设计资源网站
- CSS3 Media Queries 特性的妙用
- 【Android笔记】org.json.JSONException: No value for
- NGUI减少drawcall 的总结
- iOS三种视图切换 (UITabBarController,UINavigationController,模态窗口)