I'm trying to change the tab view when a button is clicked. I have this code:
- (IBAction)startScratch:(id)sender {
_mainTabBar.tabBarController.selectedIndex = 1;
//Error: ^ Property tabBarController not found on type "NSTabView*"
}
The .h file has these lines of code:
@property (weak) IBOutlet NSTabView *mainTabBar;
- (IBAction)startScratch:(id)sender;
I'm assuming I should replace _mainTabBar with something, but if so, what?
As @H2CO3 mentioned, there is no tabBarController
property in NSTabView
. If you read the documentation, you’ll notice that NSTabView
provides a few selection methods, including -selectTabViewItemAtIndex:
, which you can use like so:
- (IBAction)startScratch:(id)sender {
[_mainTabBar selectTabViewItemAtIndex:1];
}
Note that the first tab is at index 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With