OutletActionViewController.h

#import <UIKit/UIKit.h>

@interface OutletActionViewController : UIViewController
{
IBOutlet UITextField *txtName;
} // expose the outlet as a property
@property (nonatomic, retain) UITextField *txtName; // declare the action
- (IBAction) btnClicked: (id) sender; @end

OutletActionViewController.m

#import "OutletActionViewController.h"

@implementation OutletActionViewController

// synthesize the property
@synthesize txtName; // display text of the textbox in the alert
- (IBAction) btnClicked: (id) sender {
NSString *str =
[[NSString alloc] initWithFormat: @"Hello, %@", txtName.text]; UIAlertView *alert =
[[UIAlertView alloc]
initWithTitle: @"Hello"
message: str
delegate: self
cancelButtonTitle: @"OK"
OtherButtonTitles: nil]; [alert show];
[str release];
[alert release];
} - (void) dealloc {
// release the outlet
[txtName release];
[super dealloc];
}

如何添加关联

-------------------------------------------------------------------------------------------

Outlet添加:
按Control同时将File's Owner拖放到IBOutlet在视图中所在的对象(eg: Text Field)
File's Owner --> Outlet

Action添加:
按Control同时将事件需要触发的控件(eg: Round Rect Button)拖放到File's Owner
选择动作的指定函数
Action --> File's Owner

最新文章

  1. 《徐徐道来话Java》(2):泛型和数组,以及Java是如何实现泛型的
  2. 如何在Webstorm/Phpstorm中设置连接FTP,并快速进行文件比较,上传下载,同步等操作
  3. Java基础-输入输出-3.编写BinIoDemo.java的Java应用程序,程序完成的功能是:完成1.doc文件的复制,复制以后的文件的名称为自己的学号姓名.doc。
  4. angular之自定义过滤器的使用
  5. HDU 1695
  6. (C/C++) 基础问答题
  7. C++ 中类的构造函数理解(二)
  8. POJ 1068 AC 2014-01-07 15:24 146人阅读 评论(0) 收藏
  9. Makefile学习与进阶之Makefile.am和$$(M)的意思
  10. PHP单例模式编写
  11. Xcode升级7.3 自动补全不提示导入的自定义类解决方案
  12. Swift - 使用UI Dynamics给UIKit组件添加重力和碰撞行为
  13. Adobe After Effects 2017-14.0安装教程
  14. Centos 7.3 安装mysql5.7.19 各种调试就不多说了
  15. MVC中使用Echart后台加载数据 实现饼图、折线图、全国地图数据,单击双击事件等
  16. Web报表工具FineReport二次开发JS之字符串
  17. typecho设置文章密码保护
  18. Node.js 事件循环机制
  19. KAFKA跨主机部署网络不通解决思路
  20. bzoj千题计划269:bzoj2655: calc (拉格朗日插值)

热门文章

  1. Android 超仿Path时间轴和扇形菜单的效果
  2. list用法详解
  3. 36、Android Bitmap 全面解析
  4. 过度拟合(overfitting)
  5. lighttpd为什么要accept多次呢
  6. mybatis系列-08-动态sql
  7. Tkinter教程之Button篇(2)
  8. Codeforces 364
  9. 【SPOJ】Transposing is even more fun!
  10. Unity3D-美术相关