PDA

View Full Version : Logic thinking




jnoxx
May 26, 2011, 07:00 AM
Hai Guys, I have been coding so many hours to finish 4 apps this week. And now I am really tired, and can't figure out a normal solution to my problem..

Let's say I have RootViewController, and on a button click, I push a special library (which is a UIViewController.) onto the navigation stack. In there, I have a hard coded button on my nav bar, which has to be able to jump to the second slideshow. (let me know if i'm not explaining right.)

So like this.


- (IBAction) loadPage1 {
// Browser

NSMutableArray *photos = [[NSMutableArray alloc] init];
[photos addObject:[MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"Chapter1-1" ofType:@"png"]]];
// Create browser
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithPhotos:photos];
//[browser setInitialPageIndex:0]; // Can be changed if desired
[self.navigationController pushViewController:browser animated:YES];
[browser release];
[photos release];
}

And on second page I need to think of a block of code, which will allow me to switch to let's say IBAction, loadPage2 or something similair.
I was thinking of creating a pointer of the RootViewController, assign the self.parentViewController, but cast it as a (RootViewController*) but that gives back a UIViewController, and not the specific RootView.

Can't wait to hear back. ciao.



Sydde
May 26, 2011, 10:37 AM
Is there a method or property of UINavigationContoller that will give you the nav stack in the form of an array with the root view controller at index 0?

jnoxx
May 27, 2011, 04:16 AM
I'm gonna make a singleton, so it's accessable all over my app.
That is only solution so far atm ^__^

PhoneyDeveloper
May 27, 2011, 06:18 AM
I'm a little unclear what you're asking. It's common to use NSNotifications to send messages in a way that doesn't couple two classes together. Maybe you need for one of your child view controllers to send a notification that it's finished and its parent or another controller can then do whatever needs to happen next.

jnoxx
May 27, 2011, 06:58 AM
Hai Phoney, that is exactly what I builded after this post. but still, it's not remembering in what kind of "chapter" it is from let's say a book. and based upon that number, it will load another chapter, when u press the notification. that's why im building a singleton for remembering that i think.