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 Tutorials

Reply
 
LinkBack Thread Tools Display Modes
Old 06-30-2009, 07:30 AM   #26 (permalink)
New Member
 
Join Date: Jun 2009
Posts: 6
pmDavid is on a distinguished road
Default

Ok - so getters/setters in the view controllers, right? I was thinking of doing that, but I wasn't sure if that was the best way or not.


Quote:
Originally Posted by jamesbrannan View Post
BTW...this tutorial is outdated now that 3.0 is out
Oh noes... What is outdated from the tutorial, now? I've been using SDK 3.0, and haven't noticed any warnings or had any problems with it. I'm still relatively new to iphone/cocoa programming, so I'm not completely familiar with everything in the previous version to appreciate all the changes yet.

Thanks again!
pmDavid is offline   Reply With Quote
Old 07-02-2009, 03:36 PM   #27 (permalink)
New Member
 
Join Date: Mar 2009
Posts: 11
Soal is on a distinguished road
Default Navigation Controller

Quote:
Originally Posted by Soal View Post
Hi, I am new to iPhone dev. I am creating an application which load the first view with two buttons, clicking on one button direct you to the second view xib file which has the navigation bar with back button, and a search bar. clicking on search bar will lead us to another view which contains the search results.

my question is although I dont need navigation bar in the first view (view with only two regular buttons) should I set it as the root view controller for navigation controller?

I found the answer to my question:

in my AppDelegate.m

- (void)applicationDidFinishLaunchingUIApplication *)application {
//Navigation Controller implementation
RootViewController *rootViewControl = [[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil] autorelease];
navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewControl];

then we have to push each view in Navigation controller like this:

- (IBAction) pushSearchListView {
SearchListController *searchListControl = [[[SearchListController alloc] initWithNibName:@"SearchList" bundle:nil] autorelease];
[navigationController pushViewController:searchListControl animated:YES];
}

I hope it helps someone else.

Last edited by Soal; 07-02-2009 at 03:49 PM.
Soal is offline   Reply With Quote
Old 10-16-2009, 10:40 AM   #28 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 3
oldie is on a distinguished road
Default

HOw i can do it to show diferent text instead counter?
oldie is offline   Reply With Quote
Old 11-12-2009, 09:01 PM   #29 (permalink)
New User
 
jamesbrannan's Avatar
 
Join Date: Aug 2008
Location: Gaithersburg, MD
Posts: 178
jamesbrannan is on a distinguished road
Default

I will be taking down this video this weekend and replacing it. Sure, you can do it this way, but it is so much easier to do it right! Here is an response to someone asking me about this tutorial...(I will be creating a new tutorial to replace this)...it is *SO* easy to share data between xibs...

--- here is my email to the guy ----------

Well, I've been putting off doing a tutorial showing two different approaches, I was going to do it this weekend. I've been pressed for time.

Okay, so are all three Xibs loading each other from interface builder or programatically?

I.E. are you doing something similar to this? This is programatically..... (NOT HOW THE TUTORIAL DOES IT)


RSSFeedDetailViewController * detail = [[RSSFeedDetailViewController alloc] initWithNibName:@"RSSFeedDetailViewController" bundle:nil];

RSSItem * myRSSItem = [[RSSItem alloc] init];
myRSSItem.moreURL = theUrl;
myRSSItem.image = theImage;
myRSSItem.videoURL = theVideo;
myRSSItem.audioURL = theAudio;
myRSSItem.description = theDesc;
myRSSItem.title = theTitle;

detail.myRSSItem = myRSSItem;
detail.myDisplayedProgram = self.myDisplayedProgram;

[self.navigationController pushViewController:detail animated:YES];
[detail release];


What I am doing is loading the xib programatically, creating a Model object, setting its variables, and then setting a property in the viewcontroller that points the the RSSItem. In the view controller's viewDidLoad method I then initialize the view according to its newly set RSSItem. This is the way to share data between views. *** BUT NOTE *** this is not the Interface Builder way illustrated in the tutorial.

Oh, and if you really want to separate viewcontrollers, have an external "view loader" class that handles loading views...that way viewcontrollerA never refers to viewControllerB...only the shared data class. Total separation.

-------------------------

Now, if you are using one of the templates, and not using code at all to load the view, then there is a magical IB trick...

Are you creating a mainwindow, then setting up tabs or a navigationcontroller, and then having it refer to viewcontrollers in other xibs? If so, then this is going to surprise you.

1. create your model class.
2. drag an object from the library to the mainwindow.xib project window
3. change the object's class to your model class
4. have all view controllers have an IBOutlet that references the object
5. wire up all the view controllers ***To the object in the mainwindow.xib.
6. Presto, all view controllers are sharing the same data object...

A sample project is attached based on the Tabs Template. The important thing is to remember to create an iboutlet in each viewcontroller and then wire it up to the object in the mainwindow.xib that way they are all sharing the same object. To initialize, simply use the viewDidLoad (or viewDidAppear like I do in the example) to get the values from the shared object and initialize the individual views.

In your case, you can have the first two views set appropriate values in the dataobject when the user is done entering the text, or you could set it on the viewWillDissapear method....since all three views share the same data object, that data is available in the next view.

I am extremely embarrassed I didn't show this in a tutorial and even more embarrassed I left it out of my book! It is so easy.


Like I said, I will have a tutorial soon....and remember, this is for when your setting up stuff using interface builder. If using code to load nibs, just do what I do above.

And if you are writing a complex application, with many views, then for heaven's sake, don't load xibs using IB, use code!!



Thanks,
James A. Brannan
iPhone SDK: A Beginner's Guide
jamesbrannan is offline   Reply With Quote
Old 02-23-2011, 12:08 PM   #30 (permalink)
Registered Member
 
Join Date: Jan 2011
Location: Ireland
Posts: 1
orange is on a distinguished road
Default

Hey all,

I am a student form Ireland making an app for my thesis...

Im wondering about the best structure for doing this as i want to have a lot of different screens with a question on each... Would a series of view controllers be the answer?? I hope to have maybe 70 different ones and are there any good tutorials on efficient use of memory for apps of this type??


I would be grateful for any help you could give,

Cheers,
orange is offline   Reply With Quote
Old 01-21-2012, 05:06 AM   #31 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 12
sefiroths is on a distinguished road
Default

i have readed the tutorial, but i'm stuck because:
i have a cocos2d project, and wanted to add subview with UINavigationController, so i created a new xib and added navigation controller to it, linked with iboutlet, in the controller.h i have set ...ecc...
but in the end, is not displayed. surely i have forgotten something, will be useful to have all steps from the beginning.

is there some tutorial to make it?
thanks
sefiroths is offline   Reply With Quote
Reply

Bookmarks

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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 472
15 members and 457 guests
alexeir, David-T, Dj_kades, foslock, HemiMG, iAppDeveloper, jeroenkeij, LunarMoon, Mijator, Pauluz85, pipposanta, QuantumDoja, robsmy, sacha1996, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,928
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

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