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. setIcon with switch
- 2. 2 switch語句
- 3. Costomize React Routing with Switch Statement
- 4. PHP Switch with simple strings not working
- 5. One view controller with multiple views vs multiple view controller in a larger view controller
- 6. Django Switch language with i18n pattern and normal url_pattern
- 7. 覆蓋base :: switch in with package dependencies
- 8. Where clause with switch case or dynamic where
- 9. listview with switch and on checked change listener issue
- 10. AlertDialog with switch語句在Android中
- 11. Switch + TimeSpan
- 12. 在Switch Switch Cases中使用隨機數
- 13. 這是可能的Switch Switch? (C++)
- 14. switch語句中的switch語句?
- 15. switch語句8
- 16. JavaScript switch語句
- 17. c switch語句
- 18. switch語句
- 19. PHP switch()語句
- 20. switch語句
- 21. Java,switch case based
- 22. 從switch語句
- 23. Switch Statement and Case
- 24. Switch Statement Reverse
- 25. ansible switch user to sudo
- 26. Golang switch語句
- 27. c#:Switch case:if(case :)
- 28. 在switch語句
- 29. Switch case - else condition
- 30. Loop a Switch case
我想用不同的視圖來做它... –