About the structure of the navigation stack on myLauncher

71 views
Skip to first unread message

ho ming pang

unread,
May 18, 2012, 4:42:35 PM5/18/12
to myLauncher
hihi i am using the MyLauncher and its cool,,, but i have a question
that is how can i get back to the "main page" by code
i read through the source code of myLauncher.... the views used to
push using a navigation controller... but when i try to call
"popRootcontroller" and it doesnt work /口\ .... and i tried to use
modal transit and want to transit to main page but failed again.

Caleb_Bredlow

unread,
May 19, 2012, 5:10:44 PM5/19/12
to mylau...@googlegroups.com
I'm not on a mac right now to give the specific code, but you should be calling the navigation controller's pushViewController in order to get back to the main view programmatically.

ho ming pang

unread,
May 19, 2012, 5:15:15 PM5/19/12
to myLauncher
yeah.... but the structure of myLauncher's navigation controller is a
bit complicated.... i cant figure out i should alloc init which
viewcontroller...lol
thanks:D

Jarada

unread,
May 20, 2012, 8:03:31 AM5/20/12
to mylau...@googlegroups.com
Hi there :)

myLauncher does have a completely different hierarchy then the usual push/pop Apple method. It also doesn't (inherently) allow you to play around with it. The next release will change that, but for now you can go ahead and make the minor changes yourself.


This is a quick gist I put together that should work. Feel free to extend it; providing you can somehow call the closeView method of the MyLauncherViewController then you should be OK. Also understand that I've left out most of the existing code to make it easier to see the changes.

Hope this helps! Let me know how you get along...

Jarada

ho ming pang

unread,
May 20, 2012, 2:17:27 PM5/20/12
to myLauncher
thanks..... i read through the quick gist you posted.... but i only
understand part of them (deep deep sorry for any inconvenience
LOL!!!!)
so now ,, what i need to do is to call the closeView method which is
responsable for closing views within myLauncherViewController...
i followed your guide and add the (void)closeView method in the
MyLauncherViewController.h so that i can call the method in other
classes...

my application flow is something like this...
MainViewController.h ( The so called main page") -----click launcher
item--->
ViewController 2 ( and there is a close button at the top left corner
which s programmatically add in the MyLauncherItem.h) --------
navigation push-------->
ViewController 3 ---------press a button then commit a modal
transition to ------->
ViewController 4---->(!!!!!! Here is i am ,,,, i want to add a button
here that i can call the closeView method and get back to the "main
menu")

then what i did after reading you reply was.....
add @property (nonatomic, strong) MyLauncherViewController
*myLauncherViewController; into my "viewController4.h"
@synthesize myLauncherViewController = _myLauncherViewController; in
my "viewController4.m"
and call the closeView method
but failed....

and i cant undertand whats the " MyOverrideLauncherViewController" is
doing,,,
so i need to create a objective c class or what?

sorry that i have so much questions /O\
and i would be a great help for you to provide me a "easy
understanding" solution.... for example telling me what line i need to
add at which classes><

Thanks!!!! Very much and wish you having a nice day

Jarada

unread,
May 20, 2012, 2:53:36 PM5/20/12
to mylau...@googlegroups.com
Hi,

OK, that makes a little more sense in what you are trying to achieve.

First off, you are correct that I made the gist a little too complicated; I've updated it to use myLauncher related classes, and it should be slightly easier to understand how to integrate it and where the code fits.

But you could try a different tack... if you want to use the same icon as on the navigation bar later on that is. I do something similar in my own apps.


So here, we simply move the navigationItem to the right hand side of the navigation bar (so it doesn't obscure the back buttons and is always in the same place) and then replicate it when we push our next VC. Thus, the user always has a single exit. Try it on the base myLauncher code to see the effect.

I assumed you wanted a different way of closing the launched view, but if you are happy with the close item then you can just do that.

ho ming pang

unread,
May 21, 2012, 10:24:57 AM5/21/12
to mylau...@googlegroups.com
so make it in short,,, 
i knew how to close a launched view? but if i pushed another view in the launched view...
main view ->launched view- >push view...
then is there any method i can call to take me back to main view directly?
many thanks

2012/5/21 Jarada <j.com...@googlemail.com>

ho ming pang

unread,
May 21, 2012, 10:38:36 AM5/21/12
to mylau...@googlegroups.com
oh... i got it... 
what you suggested me to do is to simply "push a view with a navigation button" right?
create the push view and "pre" define the button right?
let me have try first... and again... is there a more proper way to do it... 
let say... how can i call the closeview function in a view controller manually??? 

2012/5/21 ho ming pang <stefani...@gmail.com>

Jarada

unread,
May 21, 2012, 11:13:22 AM5/21/12
to mylau...@googlegroups.com
The second gist (https://gist.github.com/2759118) assumed you had a navigation bar in your launched view and were using the pushViewController method in order to push a new View Controller onto the stack. If this is the way you are doing things, then using the close icon that myLauncher provides is the best way to go. You do this by moving it onto the right side of the navigation bar (so that it doesn't obstruct the back buttons) and then each time before you push your next view, you set the next view to also have the same close icon (so that it can also close).

This way, the 'main view' sets the close icon on the left of your 'launched view' (this already happens), your launched view moves this to the right (you add this code as shown in your viewDidLoad method), and then passes it onto your 'push view' (an example shown in the openView method).

In order to call the closeView function manually, you first have to have a link to the MyLauncherViewController in your 'push view' so you can call the closeView method (as shown in the first gist, https://gist.github.com/2757779). This is done by adding a link to MyLauncherViewController in your 'launched view' and your 'push view'. Then in your main view's launcherViewItemSelected: method (which you override), you pass this onto your 'launched view', and can then pass it to your 'push view' after that. Your 'push view' can then use that link to call closeView and voila!

If you still don't quite get it (and it's OK if you don't), then if you can show me the code you are trying to edit (either through these GoogleGroups or we can talk outside them if you like), then I can point you in the right direction.

On Monday, 21 May 2012 15:38:36 UTC+1, ho ming pang wrote:
oh... i got it... 
what you suggested me to do is to simply "push a view with a navigation button" right?
create the push view and "pre" define the button right?
let me have try first... and again... is there a more proper way to do it... 
let say... how can i call the closeview function in a view controller manually??? 

2012/5/21 ho ming pang
so make it in short,,, 

i knew how to close a launched view? but if i pushed another view in the launched view...
main view ->launched view- >push view...
then is there any method i can call to take me back to main view directly?
many thanks


2012/5/21 Jarada
Hi,
On 5月20日, 下午8時03分, Jarada wrote:
Message has been deleted

ho ming pang

unread,
May 21, 2012, 12:04:31 PM5/21/12
to mylau...@googlegroups.com
i have implemented the push view with navigation item
but i still have problem override that method... as i dont reli know what should i replace (MyLaunchedClass *
with... so the easiest way is .... i have create a project which shows what my situation is

ItemViewController->PushViewController->ModalViewController ...
and i left the "backToRootView" method blank
so i think you more or less get what i want to do
lastly really thanks for your kind help

2012/5/21 Jarada <j.com...@googlemail.com>
35C.png
333.png
Jarada-myLauncher-e579159 2 (1).zip

Jarada

unread,
May 21, 2012, 12:48:05 PM5/21/12
to mylau...@googlegroups.com
Wow... I wasn't expecting a full-blown project, just the specific ViewControllers in question ;)

Anyway, I've searched your project and found MainViewController to extend MyLauncherViewController, and then use DeliveryShopViewConrtoller and PickUpShopViewController appropriately, which then calls your MyViewControllerTwo.

If you look in MainViewController, I've overridden the launcherViewItemSelected: method and am testing for the two 'launched views' in question that I want to be able to pass MyLauncherViewController into, and doing so.

If you then look at either of those two, I've added a property for MyLauncherViewController, synthesised, and then when you push MyViewControllerTwo, you can then pass it through MyLauncherViewController (that has been passed it by MainViewController).

MyViewControllerTwo then has a link to MyLauncherViewController and so you can then call closeView on it.

I hope this makes sense ^^


On Monday, 21 May 2012 17:04:31 UTC+1, ho ming pang wrote:
i have implemented the push view with navigation item
but i still have problem override that method... as i dont reli know what should i replace (MyLaunchedClass *
with... so the easiest way is .... i have create a project which shows what my situation is

ItemViewController->PushViewController->ModalViewController ...
and i left the "backToRootView" method blank
so i think you more or less get what i want to do
lastly really thanks for your kind help

2012/5/21 Jarada
The second gist (https://gist.github.com/2759118) assumed you had a navigation bar in your launched view and were using the pushViewController method in order to push a new View Controller onto the stack. If this is the way you are doing things, then using the close icon that myLauncher provides is the best way to go. You do this by moving it onto the right side of the navigation bar (so that it doesn't obstruct the back buttons) and then each time before you push your next view, you set the next view to also have the same close icon (so that it can also close).
Jarada-Return.zip

ho ming pang

unread,
May 21, 2012, 2:27:39 PM5/21/12
to mylau...@googlegroups.com

oh....i think i attached wrong project lol....
its now 2:26 am...i was asleep.... but i worth me to have a brief look

ho ming pang

unread,
May 21, 2012, 2:37:39 PM5/21/12
to mylau...@googlegroups.com
in fact this is what i wanted to send you,,,you may have a look,, and give me a model answer
i think i should be able to work it out by myself,,, let me try for a while first


2012/5/22 ho ming pang <stefani...@gmail.com>
35C.png
Jarada-myLauncher-e579159.zip

ho ming pang

unread,
May 21, 2012, 3:14:13 PM5/21/12
to mylau...@googlegroups.com

can you have a look of the new attached project? and guve me some advices? thanks

35C.png

Jarada

unread,
May 23, 2012, 6:13:28 AM5/23/12
to mylau...@googlegroups.com
Hey there,

That's an easier project to work with, and it definitely helps having code to work with as I can see what you are trying to achieve.

Here is the code for your project that works. Have a look at the comments I've added. The files modified are:

MyLauncherViewController.h (as discussed previously)
RootViewController.m (to pass on link to MyLauncherViewController)
ItemViewController.h/.m (to store and pass on link to MyLauncherViewController)
PushViewController.h/.m (to store link to MyLauncherViewController and dismiss ModalViewController appropriately; also deals with dismissing to root)
ModalViewController.h/.m (this adds a Protocol for delegation so that PushViewController can respond to ModalViewController's dismissal)

Because ModalViewController is not part of the NavigationController, you need to dismiss this first so that the NavigationController becomes the top-most view, as MyLauncherViewController dimisses whatever the top-most view is.


On Monday, 21 May 2012 20:14:13 UTC+1, PandaMing wrote:

can you have a look of the new attached project? and guve me some advices? thanks

2012-5-22 上午2:37 於 "ho ming pang"  寫道:
in fact this is what i wanted to send you,,,you may have a look,, and give me a model answer
i think i should be able to work it out by myself,,, let me try for a while first


2012/5/22 ho ming pang

oh....i think i attached wrong project lol....


its now 2:26 am...i was asleep.... but i worth me to have a brief look

Jarada-Return2.zip

PandaMing

unread,
Jun 4, 2012, 12:44:35 AM6/4/12
to mylau...@googlegroups.com
oh....sorry for late reply!!
thank you so much.. and its exactly what i need...thank you and thankyou so much:D


PandaMing於 2012年5月19日星期六UTC+8上午4時42分35秒寫道:
Reply all
Reply to author
Forward
0 new messages