Reputation: 6594
I've got a button on one of my views and I want it to open another view from the tab bar (the view has already been loaded by the app delegate) and then activate one of that view's selectors, which opens a UIActionSheet. This is what I'm doing so far for switching to the other view:
- (void)btnOpenOtherViewPressed:(id)sender
{
[self.tabBarController setSelectedIndex:4];
}
This brings me to the other window, but I can't find a way of sending a signal to the other view controller saying I want to open the UIActionSheet when switching to the view by pressing that button rather than using the tab bar.
Upvotes: 0
Views: 215
Reputation: 569
You can use notification for this message passing:
- (void)btnOpenOtherViewPressed:(id)sender
{
[self.tabBarController setSelectedIndex:4];
[[NSNotificationCenter defaultCenter] postNotificationName:@"btnOpenOtherViewPressed" object:nil];
}
Add this code to destination view in viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showActionSheet:) name:@"btnOpenOtherViewPressed" object:nil];
And add this method:
-(void)showActionSheet:(NSNotification *)notification{
}
Upvotes: 1