Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-12-2011, 02:40 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 7
dotdash is on a distinguished road
Default Custom UIViewcontroller class n00bish question

Hi,

So honestly I might just be thinking about this entire situation incorrectly, so if you think that's the case please say so, I would like some input.

(I am not using a TabBarController because it's not right for this particular app.)

In my app, I have three separate views with their own view controller, each as a subclass of UIViewController. I also have one view and view controller that acts as sort of a god class, that contains outlets and actions that allow the other views to be loaded. In my app delegate's viewdidload, I call

Code:
	[window addSubview:viewController.view];
    [window makeKeyAndVisible];
So the application launches, and it loads the view of the "god" view controller. This view contains a button, and when it is pressed, I want it to load a different view controller's view. I was able to do this successfully, by using

Code:
	[self clearView];
	[self.view insertSubview:firstView.view atIndex:1];
where clearView is a self contained action that just removes the god view controllers view from the superview.

On the "firstView.view" I have a button that calls an action within firstView's view controller, that goes back to the "god" view controller's view. This is all working correctly, even if I feel like it's not the best way of doing this.

So my question is, in terms of indirection and object oriented programming, is there a way to essentially make the firstView's, secondView's, and thirdView's view controller a subclass of the god view controller, so that from within for instance firstView's view controller, I can call an action or access a property that exists in the god view controller?

My goal is to use the god view controller to do handle all of the switching of views, but then use those other view's view controller's to handle what is going on in their respective views.

An example would be, from the firstView view controller, to call an action "loadSecondView" that exists in the god view controller. What is the best way to do this, if at all?

Again, if I am approaching this whole scenario wrong, say so. I will take any input that I can get!
dotdash is offline   Reply With Quote
Old 01-12-2011, 02:44 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Why not just use a navigation controller?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-12-2011, 02:47 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 7
dotdash is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Why not just use a navigation controller?
I don't want the appearance of a navigation controller because it doesn't really apply to the app I am working with. It is a very simple game. I will check out the documentation for Navigation Controller's though, I hadn't explored that yet. Is it possible to use one without having a navigation bar, etc? Sorry if that's a stupid question.
dotdash is offline   Reply With Quote
Old 01-12-2011, 02:48 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

The bar does not have to be displayed.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-12-2011, 02:49 PM   #5 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 7
dotdash is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
The bar does not have to be displayed.
Just realized that as I clicked submit! Thanks Brian, I really appreciate the prod in the right direction.
dotdash is offline   Reply With Quote
Old 01-12-2011, 02:55 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 7
dotdash is on a distinguished road
Default

For anybody who might run into the same or a similar issue, here is a really helpful article regarding just this! It seems all I needed was the right way of phrasing it.

iPhone Programming Tutorial ? Transitioning Between Views | iCodeBlog
dotdash is offline   Reply With Quote
Reply

Bookmarks

Tags
uiview, uiviewcontroller, view, viewcontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 365
9 members and 356 guests
7twenty7, blueorb, iAppDeveloper, iGamesDev, Mah6447, Morrisone, mottdog, sacha1996, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:36 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0