如何製作多內聯UISegmentedControl。我需要它有6個按鈕,每行3個。我如何以編程方式執行此操作?多內聯UISegmentedControl
3
A
回答
6
您將需要使用其中的兩個,使用selectedSegmentIndex
屬性。如果當您從一個控件獲取操作時,將其他控件的屬性值設置爲-1
,它將有效地爲您提供兩行中的六個按鈕組,這兩個按鈕似乎作爲一個組鏈接在一起。
1
只需將代碼添加到@Adam埃伯巴赫的回答是:
在viewDidLoad
[self.orderOptionsSegmentedControl1 addTarget:self action:@selector(disableOtherSegmentedControl:) forControlEvents:UIControlEventValueChanged];
[self.orderOptionsSegmentedControl2 addTarget:self action:@selector(disableOtherSegmentedControl:) forControlEvents:UIControlEventValueChanged];
然後實現disableOtherSegmentedControl
- (void) disableOtherSegmentedControl:(id)sender
{
if (sender == self.orderOptionsSegmentedControl1)
{
self.orderOptionsSegmentedControl2.selectedSegmentIndex = -1;
}
else if (sender == self.orderOptionsSegmentedControl2)
{
self.orderOptionsSegmentedControl1.selectedSegmentIndex = -1;
}
}
相關問題
- 1. UISegmentedControl與多行
- 2. XSL-FO多個表內聯
- 3. SQL多內部聯接
- 4. simple_form多輸入內聯
- 5. UISegmentedControl在UIView內沒有響應
- 6. 視圖一次只能與最多一個視圖控制器關聯(UISegmentedControl)
- 7. 的ModelAdmin - 許多一對多內聯
- 8. UISegmentedControl段
- 9. 在UISegmentedControl
- 10. Swipeable UISegmentedControl
- 11. 從UISegmentedControl
- 12. UISegmentedControl EXC_BAD_ACCESS
- 13. 鈦 - uisegmentedcontrol
- 14. 導航欄中的多選UISegmentedControl
- 15. UISegmentedControl中多個段的選擇
- 16. 多個內聯腳本比一個聯合內聯腳本慢嗎?
- 17. 內聯或不內聯
- 18. UISegmentedControl,UIToolbar和UINavigationItem
- 19. UISegmentedControl與UITableView
- 20. UIToolbar中的UISegmentedControl
- 21. NSInvalidArgumentException使用UISegmentedControl
- 22. IOS 6 UISegmentedControl
- 23. UISegmentedControl setSelectedSegmentIndex問題
- 24. 問題UISegmentedControl
- 25. UISegmentedControl與按鈕
- 26. UISegmentedControl tintColor不iOS7
- 27. UISegmentedControl定製
- 28. 方角UISegmentedControl
- 29. UISegmentedControl未重繪
- 30. 如何從UISegmentedControl
智能和簡單的方法來做到這一點。謝謝。我可能只是補充說,你可以使用`[self.orderOptionsSegmentedControl addTarget:self action:@selector(disableOtherSegmentedControl :) forControlEvents:UIControlEventValueChanged];`來檢測一個`UISegmentedControl`的選擇,我只是將代碼放在一個希望有人需要它的新答案。 – Ali 2013-09-23 09:43:28