所以我在对象库中找不到复选框。我只有一个名为Objects的文件夹。如何将文件夹添加到对象库中的复选框?
答案 0 :(得分:4)
iOS不提供标准的复选框控件。它提供了一个开关(UISwitch
),它与复选框大致相同,但看起来不同。这就是你想要的吗?
答案 1 :(得分:0)
以下是如何从按钮创建复选框(您需要将操作连接到此方法并连接名为checkboxout
的属性)。搜索SO以获取其他示例,我只是从我的一个程序中复制了它。如果这没有意义,那么你应该做一些基本的Objective-c / xcode教程。 (我听说Ray Wenderlich做得很好http://www.raywenderlich.com/)
您知道,如果您可以使用开关,Jonathan的答案是更好的做事方式。
- (IBAction)checkbox:(id)sender
{
UIButton *b = checkboxout;
if (!boxChecked)
{
boxChecked = YES;
[b setImage:isCheck forState:UIControlStateNormal];
checkboxState = [NSNumber numberWithBool:boxChecked];
return;
}
if (boxChecked)
{
boxChecked = NO;
[b setImage:notCheck forState:UIControlStateNormal];
checkboxState = [NSNumber numberWithBool:boxChecked];
return;
}
}
//whatever your init method is for your view
{
isCheck = [UIImage imageNamed:@"checkbox_checked.png"];
notCheck = [UIImage imageNamed:@"checkbox_unchecked.png"];
//probably other stuff
}