【ios6.0 自学瞎折腾】(二)控件交互和对话框
来源:互联网 发布:每月数据统计分析报表 编辑:程序博客网 时间:2024/06/16 09:21
上篇是错了,故事模板再创建的时候可以不勾选,主要创建出来的项目就会有xib文件了。
下面是程序配置界面
如上篇,拖入一个按钮,双击改名。接下来很重要一步喔,选中这个按钮,按住你键盘上的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 自学瞎折腾】(一) Helloworld!
- 【IOS6.0 自学瞎折腾】(四)Xib可视化编程
- 【IOS6.0 自学瞎折腾】(五)应用程序的启动过程和Application生命周期
- 【ios6.0 自学瞎折腾】(三)表示图填充数据
- 自定义控件自学笔记(二)
- IOS6之AutoLayout(二)
- IOS6之AutoLayout(二)
- IOS6之AutoLayout(二)
- 数组大折腾。(二)
- 折腾二维数组(二)
- WTL入门(4)--- 对话框和控件
- 对话框和常用控件
- 对话框和常用控件
- MFC对话框和控件
- 使用对话框和控件
- MFC对话框和控件
- Android示例-JavaScript与UI控件交互(二)
- 【ios6.0 自学瞎折腾】(一) Helloworld!
- [windows phone自学笔记] 第一篇 HelloWorld!
- Win8应用开发 入门篇(一) Hello world!
- [windows phone自学笔记] 第二篇 Button控件
- Win8应用开发 入门篇(二)富文本和消息框
- 【ios6.0 自学瞎折腾】(二)控件交互和对话框
- 【ios6.0 自学瞎折腾】(三)表示图填充数据
- WebService(一)Hello world!和IIS配置
- AndroidのBitmap之大图片优化
- AndroidのIntent之传递List
- AndroidのActivity之退出返回栈(二)
- AndroidのBitmap之圆形头像
- Myeclipse 8.5安装Python插件PyDev
- AndroidのBitmap之Scaletype