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];
And the Target :
- (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];
}
Now I am making a simple custom UIButton
, I want to check if the checkbox is checked or not using this custom UIButton
and NSLog the same i.e If the checkBox is checked then on button click it should NSLog that the checkBox is checked..!
Can anyone help me with this..?
Any help will be truly appreciated.
Thanks for your time
Shailesh