iOS應用程序的對象庫中是否存在任何複選框控件?我看到的最接近的是開關控件,它可以採用布爾值。iOS應用程序的複選框控件
回答
您可以使用一個UIButton的選中狀態,設置不同的圖像(或者也文本)的型動物(通過代碼或Interface Builder中):
[button setImage:[UIImage imageNamed:@"selected.png"]
forState:UIControlStateSelected];
[button setImage:[UIImage imageNamed:@"unselected.png"]
forState:UIControlStateNormal];
而且在觸摸的內心操作:
- (IBAction)buttonTouched:(id)sender
{
button.selected = !button.selected;
// add other logic
}
對我來說非常有用。謝謝..... – Vaquita 2012-11-28 14:09:58
這是一個開源庫,爲它提供實現。 https://github.com/t4ku/RadioButtonWithUIKit – 2013-03-04 09:20:55
不起作用。你必須採取UIImageView。 – 2014-01-06 10:18:54
這是我用於屏幕上的兩個複選框的代碼。 (我把它們放在屏幕上的兩張圖片的底部,我用UIControlEventTouchDown調用checkBoxTapped方法,這個方法和我的主視圖控制器對話,我決定答案是否正確或不正確,然後主視圖控制器調用回該視圖並告訴它的空白文本框更改爲一個檢查:
或x
// Put the Checkboxes on the screen
UIImage *checkBox = [UIImage imageNamed:@"Checkbox"];
self.checkBoxLeft = [UIButton buttonWithType:UIButtonTypeCustom];
[self.checkBoxLeft setImage:checkBox forState:UIControlStateNormal];
[self.checkBoxLeft setFrame:checkBoxFrameLeft];
[self.checkBoxLeft addTarget:self
action:@selector(checkBoxTapped:)
forControlEvents:UIControlEventTouchDown];
[self.checkBoxLeft setTitle:@"checkBoxLeft" forState:UIControlStateNormal];
self.checkBoxLeft.contentEdgeInsets = insets;
self.checkBoxLeft.showsTouchWhenHighlighted = NO; // Keeps it from turning gray
self.checkBoxRight = [UIButton buttonWithType:UIButtonTypeCustom];
[self.checkBoxRight setImage:checkBox forState:UIControlStateNormal];
[self.checkBoxRight setFrame:checkBoxFrameRight];
[self.checkBoxRight addTarget:self
action:@selector(checkBoxTapped:)
forControlEvents:UIControlEventTouchDown];
[self.checkBoxRight setTitle:@"checkBoxRight" forState:UIControlStateNormal];
self.checkBoxRight.contentEdgeInsets = insets;
self.checkBoxRight.showsTouchWhenHighlighted = NO; // Keeps it from turning gray
- (void)checkBoxTapped:(UIButton *)buttonPressed {
[[self delegate] checkBoxTapped:buttonPressed.currentTitle];
}
- (void)highlightCheckbox:(NSString *)checkboxToHighlight withHighlight:(NSString *)highlight {
if ([checkboxToHighlight isEqualToString:@"left"]){
[self.checkBoxLeft setImage:[UIImage imageNamed:highlight] forState:UIControlStateNormal];
} else {
[self.checkBoxRight setImage:[UIImage imageNamed:highlight] forState:UIControlStateNormal];
}
}
//定義按鈕
的屬性聲明未經檢查的圖片
- (void)viewDidLoad
{
[_checkboxButton setBackgroundImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal];
}
檢測圖像。
- (IBAction)buttonTapped:(id)sender
{
if (_checkboxButton.selected == YES)
{
[_checkboxButton setBackgroundImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateSelected];
_checkboxButton.selected = NO;
}
else
{
[_checkboxButton setBackgroundImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];
_checkboxButton.selected = YES;
}
}
- 1. 應用程序崩潰,當我使用複選框控件
- 2. AlertView with iOS中的複選框控件
- 3. HTML應用程序「複選框」響應
- 4. iOS提醒應用程序,如複選框
- 5. 應用程序時,點擊複選框
- 6. IOS應用程序複製
- 7. 如何處理Windows安裝程序中的複選框控件?
- 8. 檢測的iOS複選框插件的複選框狀態
- 9. 使用引導程序的iOS複選框不會中心
- 10. 複選框在GridView控件
- 11. ASP.NET複選框控件
- 12. 選項卡上的複選框應用程序
- 13. 只有當複選框勾選閃亮的應用程序R
- 14. 控制和選擇從ios的應用程序的WiFi
- 15. 應用程序做對面的複選框應該做什麼
- 16. 的iOS應用程序框架
- 17. 聯網iOS應用程序的框架?
- 18. 在複選框列表控件中獲取複選框的值
- 19. 刪除ASP.NET複選框控件中的勾號/複選框
- 20. 列表框和複選框 - XAML/C# - Windows 8應用程序
- 21. 使用複選框作爲gridview控件
- 22. ASP.NET用戶控件複選框OnCheckedChanged
- 23. 使用java小應用程序的複選框setstate
- 24. 調整Windows通用應用程序中的複選框
- 25. 用Shiny應用程序中的複選框切換ggvis圖層
- 26. 用於Windows應用程序的互斥複選框
- 27. Android - 複選框/單選按鈕分數測驗應用程序
- 28. 幫幫我!選擇複選框時,應用程序崩潰
- 29. Css爲html複選框控件工作,而不是爲asp.net複選框控件
- 30. 複選框控件啓用表單上的其他控件
UISegmentedControl可以幫助你 – 0xDE4E15B 2012-02-22 07:48:23
使用的UIButton狀態爲選中/清除標記。放入圖片取消選中(正常狀態)並選中(選中狀態)。 – Hirak 2012-02-22 07:49:59
沒有沒有默認的用戶界面控制複選框或單選按鈕,在這裏你必須使用2個不同的圖像進行檢查和未選中,並在邏輯上控制它們 – kulss 2012-02-22 07:49:35