我在我的UIButton代碼中使用了customview。與UIButton相關的問題
UIButton *button= [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
[button addTarget:self action:@selector(checkedimage:) forControlEvents:UIControlEventTouchUpInside];
-(IBAction)checkedimage:(id)sender
{
NSLog(@"checkedimage");
if(checkImage == NO)
{
newImage = [UIImage imageNamed:@"a.png"];
checkImage=YES;
}
else if(checkImage==YES)
{
newImage = [UIImage imageNamed:@"b.png"];
checkImage=NO;
}
}
,但是當我在UIButton的點擊是不會行動checkedimage
爲什麼呢?
你不會在視圖中添加按鈕,也沒有按鈕框架,所以設置所有這些東西.. – 2012-07-18 06:28:04