【ios6.0 自学瞎折腾】(二)控件交互和对话框
2012-12-27 22:16
309 查看
上篇是错了,故事模板再创建的时候可以不勾选,主要创建出来的项目就会有xib文件了。
下面是程序配置界面
如上篇,拖入一个按钮,双击改名。接下来很重要一步喔,选中这个按钮,按住你键盘上的control键,记住是ctrl而不是苹果键喔,然后用鼠标拖动到下图处,这时会有一个箭头指向File's Owne,然后会弹出你写的方法。
选中这个按钮,我们可以查看这个按钮的所有事件:
方法怎么写呢??
首先再ViewController.h里申明一个方法;
然后在ViewController.m里写具体方法实现:
下面是程序配置界面
如上篇,拖入一个按钮,双击改名。接下来很重要一步喔,选中这个按钮,按住你键盘上的control键,记住是ctrl而不是苹果键喔,然后用鼠标拖动到下图处,这时会有一个箭头指向File's Owne,然后会弹出你写的方法。
选中这个按钮,我们可以查看这个按钮的所有事件:
方法怎么写呢??
首先再ViewController.h里申明一个方法;
#import <UIKit/UIKit.h> @interface ViewController : UIViewController -(IBAction)showMessage;//返回IBAction类型 @end
然后在ViewController.m里写具体方法实现:
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(IBAction)showMessage { UIAlertView *mAlert = [[UIAlertView alloc]initWithTitle:@"第一个应用demo" message:@"Hello world" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [mAlert show]; } @end
UIAlertView alloc:给mAlert分配内存空间;
initWithTitle:message:delegate:cancelButtonTitle:otherButtonTiles:;初始化mAlert 带标题,消息,取消确定按钮等参数,是不是有点像android呢?呵呵! 然后给mAlert对象发送show消息,这样就把对话框给show出来了!!
相关文章推荐
- 【ios6.0 自学瞎折腾】(二)控件交互和对话框
- 【IOS6.0 自学瞎折腾】(五)应用程序的启动过程和Application生命周期
- 【ios6.0 自学瞎折腾】(一) Helloworld!
- 【IOS6.0 自学瞎折腾】(四)Xib可视化编程
- 【IOS6.0 自学瞎折腾】(四)Xib可视化编程
- 【ios6.0 自学瞎折腾】(一) Helloworld!
- 【IOS6.0 自学瞎折腾】(五)应用程序的启动过程和Application生命周期
- 【ios6.0 自学瞎折腾】(三)表示图填充数据
- 【ios6.0 自学瞎折腾】(三)表示图填充数据
- iOS 原生控件和HTML5的交互
- 苹果 IOS界面交互控件一览
- vc++学习日记 与对话框控件交互的七种方法
- iOS自学笔记之UILabel控件
- ios与javascript的交互,适合刚接触电商ios与html5混编的朋友,(ios自学笔记)
- iOS 原生控件与web的简单交互
- iOS 12 人机交互指南(九):控件(Controls)
- iOS自学笔记之UIButton控件
- 阻止IE弹出“在此页上的 ActiveX 控件和本页上的其他部份的交互可能不安全。你想允许这种交互吗?”对话框
- IOS的基本控件的使用-警告对话框&等待提示器
- [黑马IOS自学第一篇]IOS界面编程,IOS开发体验,控件初步认识