UIBUTTON点击事件
来源:互联网 发布:java ee tag标签文件 编辑:程序博客网 时间:2024/05/22 02:22
#import "Person.h"
@implementation AppDelegate
- (void)dealloc
{
[_arrrelease];
[self.windowrelease];
[superdealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]]autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColorwhiteColor];
[self.windowmakeKeyAndVisible];
/*
UIButton
*/
//按钮实例化
UIButton *b = [UIButtonbuttonWithType:UIButtonTypeDetailDisclosure];
b.frame =CGRectMake(0,20, 50, 50);
//给按钮设置标题(普通状态下)
[b setTitle:@"1"forState:UIControlStateNormal];
// 修改标题颜色
[b setTitleColor:[UIColorblackColor] forState:UIControlStateNormal];
//高亮状态下的标题
[b setTitle:@"2"forState:UIControlStateHighlighted];
//按钮不可被点击的状态
[b setTitle:@"3"forState:UIControlStateDisabled];
//按钮不可接受点击事件
// b.enabled = NO;
//按钮的事件机制
//添加点击事件
/*
UIControlState 状态
UIControlEvents 事件
改变空间的状态必须有事件
*/
//UIControlEventTouchUpInside 按下并且抬起
//必须要实现@selector方法不实现崩溃
/*
当b有UIControlEventTouchUpInside(按下并抬起)事件时会在self当前对象中调用@selector的方法
*/
//成员变量不能使用加方法
/*
_arr =@[@"123",@"12341"];
_arr =[[[NSArray alloc] initWithObjects:@"1",@"2",@"3", nil] autorelease];
*/
//正确写法
_arr = [NSArrayarrayWithObjects:@"1",@"2",@"3",nil];
_arr = [[[NSArrayalloc] initWithObjects:@"1",@"2",@"3",nil] retain];
//Person *p =[[Person alloc] init]; 在addTarget调用Person对象的话,会触发Person的click方法
[b addTarget:selfaction:@selector(click)forControlEvents:UIControlEventTouchUpInside];
[self.windowaddSubview:b];
return YES;
}
bool flag =0;
-(void)click
{
NSLog(@"click");
if (flag) {
self.window.backgroundColor = [UIColorblackColor];
}else{
self.window.backgroundColor = [UIColorwhiteColor];
}
flag = !flag;
}
- UIButton点击事件不起作用
- UIBUTTON点击事件
- UIButton 的点击事件
- UIButton点击无法响应事件
- UIButton的响应点击事件
- UIButton添加block点击事件
- UIButton无法响应点击事件
- Swift开发:UIButton点击事件
- UIButton基础以及使用block+UIButton处理点击事件
- ios UIButton点击事件(@selector)注意事项
- UIButton无法响应点击事件问题
- runtime - UIButton点击事件重复处理
- UIButton无法响应点击事件问题
- UIButton 点击事件响应延迟 问题解决
- iOS UIButton 点击事件带多参数
- UIButton小技巧----点击事件时间间隔
- UIButton小技巧----点击事件的范围
- ios UIButton的点击与松开事件处理
- CART算法实现之可视化
- Souliss – 分布式家庭自动化和物联网
- Facebook 2013年的9个开源项目
- 表示 十六进制字符串 对 10取模的方法
- java 1.6新特性
- UIBUTTON点击事件
- JVM学习(1)
- Unity与FBX--为什么使用FBX文件
- eclipse设置字体
- java 1.7新特性
- 如何获得数组的长度
- ADT稀疏矩阵 及 转置
- perl
- div节点的操作(添加,删除,替换,克隆)