I am trying to make a menu using checkboxes, which i have created programmatically. Heres how i made my checkBox:
UIButton* checkBox = [[UIButton alloc] initWithFrame:CGRectMake(60,60,300, 44)];
[checkBox setImage:[UIImage imageNamed:@"unmarked.png"] forState:UIControlStateNormal];
[checkBox addTarget:self action:@selector(toggleButton:) forControlEvents: UIControlEventTouchUpInside];
[checkBox setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
[self.view addSubview:checkBox];
具体目标:
- (void)toggleButton: (id) sender
{
checkboxSelected = !checkboxSelected;
UIButton* check = (UIButton*) sender;
if (checkboxSelected == NO)
[check setImage:[UIImage imageNamed:@"unmarked.png"] forState:UIControlStateNormal];
else
[check setImage:[UIImage imageNamed:@"marked.png"] forState:UIControlStateNormal];
}
现在,我正在做一个简单的习俗:UIButton
,我想检查检查检查箱是否使用这一习俗(
谁能帮助我这样做?
任何帮助都将得到真正赞赏。
感谢您的时间
Shailesh