0
A
回答
1
執行以下操作
- (void)viewDidLoad //of mainViewController {
//do viewController1 alloc init // Gray Color
[self.view addSubview:viewController1.view];
//do viewController2 alloc init //Red Color
[self.view addSubview:viewController2.view];
[viewController2.view setHidden:YES];
}
//assign this method to segmented controls' valueChanged event
- (IBAction)segmentControlClicked:(id)sender {
UISegmentedControl *segmentedControl = (UISegmentedControl *)sender; // if segmented control is not declared as an IBOutlet
if (segmentedControl.selectedSegmentIndex == 0) {
[viewController1.view setHidden:NO];
[viewController2.view setHidden:YES];
}
else if (segmentedControl.selectedSegmentIndex == 1) {
[viewController2.view setHidden:NO];
[viewController1.view setHidden:YES];
}
}
確保 'Y' 起源viewController1和viewController2是分段的控制之下,這樣的分割控制不隱藏。
1
你可以在廈門國際銀行雙視角和主視圖,在視圖中添加這兩種觀點做負載,並設置爲隱藏的一個屬性,它不想顯示,然後設置隱藏屬性TRUE或關閉開關控制事件的FALSE。
0
請嘗試以下
- (IBAction)segmentControlClicked:(id)sender {
if (!viewController1) {
//do alloc init
}
if (!viewController2) {
//do alloc init
}
UISegmentedControl *segmentedControl = (UISegmentedControl *)sender;
if (segmentedControl.selectedSegmentIndex == 0) {
[viewController1.view setHidden:NO];
[viewController2.view setHidden:YES];
}
else if (segmentedControl.selectedSegmentIndex == 1) {
[viewController2.view setHidden:NO];
[viewController1.view setHidden:YES];
}
}
+0
我如何將它添加到該視圖(圖片中是灰色的)? –
+0
已添加新答案。請閱讀 – Sahil
相關問題
- 1. Costomize React Routing with Switch Statement
- 2. PHP Switch with simple strings not working
- 3. One view controller with multiple views vs multiple view controller in a larger view controller
- 4. Where clause with switch case or dynamic where
- 5. Switch + TimeSpan
- 6. 在Switch Switch Cases中使用隨機數
- 7. switch語句中的switch語句?
- 8. switch語句8
- 9. JavaScript switch語句
- 10. c switch語句
- 11. switch語句
- 12. Java,switch case based
- 13. ansible switch user to sudo
- 14. Golang switch語句
- 15. Switch case - else condition
- 16. Method.Invoke()vs switch
- 17. 在switch語句
- 18. switch語句
- 19. PHP switch語句
- 20. if和switch語句
- 21. 在switch語句
- 22. Switch Case to/Between
- 23. Go switch through through
- 24. switch語句
- 25. SQL switch語句
- 26. rxjs switch unwrapping observable
- 27. 的switch-case(')
- 28. Enum.Parse()或Switch
- 29. DataProvider Switch/Singleton?
- 30. switch linq語法
我想用不同的視圖來做它... –