Re: Fade when changing window's rootViewController possible?
Re: Fade when changing window's rootViewController possible?
- Subject: Re: Fade when changing window's rootViewController possible?
- From: David Duncan <email@hidden>
- Date: Mon, 09 Nov 2015 09:40:57 -0800
> On Nov 7, 2015, at 11:31 PM, Diederik Meijer <email@hidden> wrote:
>
> Thank you David,
>
> I forgot to mention that one of them is a UISplitViewController and - unless this has changed - that one can not be presented modally.
I’m not aware of any particular reason why a split view controller could not be presented modally. Alternatively you could present the other view controller with no animation and then dismiss it when you want to reveal the split view controller.
> It is for this reason that I want to switch the window’s rootViewController. Otherwise, a plain presentViewController would definitely make a lot more sense :-)
>
> This is what I actually found briefly after sending the question (method edited for my app’s specifics and original code found not in a separate method).
>
> Method added to appDelegate:
>
> -(void)switchWindowRootVCTo:(NSString *)newVCString {
> id newVC = nil;
> if ([newVCString isEqual:@"UISplitViewController"]) newVC = self.svc;
> else if ([newVCString isEqual:@"THWelcomeVC"]) newVC = self.wvc;
> self.window.rootViewController = newVC;
> [UIView transitionWithView:self.window
> duration:0.50
> options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
> self.window.rootViewController = newVC;
> }
> completion:nil];
> }
>
> So both the old and the new root VC are properties of the appDelegate (self.svc and self.wvc respectively) and they are both initialized in applicationDidiFinishLaunching.
>
> Each of them can call the above method of the app delegate and trigger the switch.
>
>
> Best regards,
>
>
>
> Diederik
>
>
>
>> Op 8 nov. 2015, om 04:36 heeft David Duncan <email@hidden <mailto:email@hidden>> het volgende geschreven:
>>
>>>
>>> On Nov 7, 2015, at 1:30 PM, Diederik Meijer <email@hidden <mailto:email@hidden>> wrote:
>>>
>>> Dear list,
>>>
>>> Is it possible to change an iOS app window’s rootViewController at runtime and have a fade animation between the two states happen?
>>
>> Not trivially, but you can do this trivially by presenting your “replacement” view controller modally, which is also the more supported path (by far).
>>
>>>
>>> Obviously there is no modal or push presentation, the view is just replaced by a new one. For this reason a fade between the two would be nice.
>>>
>>> This is for iOS 8 and up, coding in Objective-C.
>>>
>>>
>>> Many thanks,
>>>
>>>
>>>
>>> Diederik
>>>
>>>
>>>
>>> _______________________________________________
>>>
>>> Cocoa-dev mailing list (email@hidden <mailto: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 <http://lists.apple.com/>
>>>
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden <mailto:email@hidden>
>>
>> --
>> David Duncan
>
--
David Duncan
_______________________________________________
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