Re: UISplitViewController some of the time
Re: UISplitViewController some of the time
- Subject: Re: UISplitViewController some of the time
- From: Conrad Shultz <email@hidden>
- Date: Thu, 03 Nov 2011 12:59:38 -0700
On 11/3/11 10:28 AM, Eric E. Dolecki wrote:
> Sorry - but I am not following you. What I just tried that almost work is:
>
> In my detail view controller for the split view controller, I added in it's
> viewDidLoad:
>
> HomeUIViewController *tmp = [[HomeUIViewController alloc] init];
> [self presentModalViewController:tmp animated:NO];
> [[NSNotificationCenter defaultCenter] addObserver:self
> selector:@selector(removeMainView:)
> name:@"removeMainView" object:nil];
>
> And added this method to the same detail view controller:
>
> - (void)removeMainView:(NSNotification *)notification {
> [self dismissModalViewControllerAnimated:YES];
> }
> In my HomeUIViewController I have a button that broadcasts that
> "removeMainView" - which causes the viewcontroller to be removed.
Sorry, didn't you want the home view to be the initial view? If so,
this seems backwards.
I'm pretty sure Matt was recommending you do something more like the
following.
In your main view controller (that is, the one initially visible), being
the HomeUIViewController, have an action that responds to your button
(typed in email, be warned):
MySplitViewController *svc = [[MySplitViewController alloc]
initWithNibName:@"MySplitViewController" bundle:nil];
[self presentModalViewController:svc animated:YES];
[svc release];
Then in MySplitViewController, have some UI that allows you to return to
the home screen, and simply call:
[self dismissModalViewControllerAnimated:YES];
No notifications needed.
As an aside, notifications are used primarily for decoupling objects and
for communicating with an indeterminate number of objects. These
conditions don't really apply here. If you need a modally presented
view controller to communicate with its presenter, it should probably
use delegation or a similar form of direct messaging.
--
Conrad Shultz
Synthetiq Solutions
www.synthetiqsolutions.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden