Option to choose which controller to display be default
FredzL opened this issue · 13 comments
I'd like to be able to choose which controller to display by default, not the first in the menu. I've got a menu where the first entry is the search page and I don't want it to be displayed by default.
You can already do this by calling one of these methods after the creation of the slideout controller:
- (void)switchToControllerTagged:(int)tag andPerformSelector:(SEL)selector withObject:(id)obj;
- (void)switchToControllerTagged:(int)tag andPerformSelector:(SEL)selector withObject:(id)obj afterDelay:(NSTimeInterval)delay;
Thank you, but unfortunately I don't understand how to use this method and I didn't find examples for it. What am I supposed to put for selector and obj ? I tested with a value of 3 for the tag and nil for the selector and obj but it didn't show my third view.
I did it by subclassing AMSlideOutNavigationController, here is my code:
#import "MySlideOutNavigationController.h"
@implementation MySlideOutNavigationController
+ (id)slideOutNavigation
{
return [[MySlideOutNavigationController alloc] init];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self switchToControllerTagged:3 andPerformSelector:nil withObject:nil];
}
@end
Works well, thanks.
The method should be called in the viewDidLoad of the first view controller presented by the slideout. You could argue that it's not a good design choice, and I would agree :D
I'll add the proper options in the next releases, same goes for the issue 31.
Sounds a bit dangerous to me if the first view controller is changed afterwards. What's the problem with doing it in a subclass of the slide controller ?
There's no problem, it's just easier if I'll introduce a couple of options. I'll do it tomorrow.
Ok, thanks.
Added the property strtingControllerTag
in commit 8aac98a
Sorry to ask this but how can i change of controller from any another child controller ? I don't think i have an handle to the slideoutController in my children controllers... Or am i doing it wrong ? :-)
Thank you in advance
You could have a property of your slideoutcontroller inside your app delegate, than you can access the controller like this:
YourAppDelegate* delegate = [UIapplication sharedApplication].delegate;
[delegate.slideOutController switchToControllerTagged:2 andPerformSelector:nil withObject:nil];
Works great. Now i need to add an animation :-)
Thank you
Thanks for adding strtingControllerTag, much cleaner this way, works well. Curious about why you named it strtingControllerTag instead of startingControllerTag, typo ?
Yep, typo, I fixed it in the last release :)