views:

38

answers:

4

In my iphone app i have a button which changes the view (to another xib file).

How can i have this xib file to contain a navigation controller with a back button (which is at the top) and the bottom part a table view that has a scrollbar?

I assume that i have to use navigation controller, uiscrollview and uitableview but i am not sure how to combine these properly in the Interface Builder.

Can anyone help me out here?

EDIT: Thanks for your answers. One annoying thing in XCode is that when you create a new xib file, you only get the empty version. However, if you create a new project for a specific purpose then you get a navigation, tab based or any other generated properly. Is there a better way to automate this?

A: 

For UINavigationController, when you click the button to change the view. you just use : [self.navigationController pushViewController:newViewController].

In the nib file, you add the navigationItem and then set the leftButton to the backButton. You can also drag the UITableViewController to the view.

vodkhang
yes, but when you have created a new xib file (which is of no certain type) what steps do you follow then to get the uinavcontroller and uitablecontroller working properly within interface builder?
immuner
A: 

I recommend that you create new "Navigation-based Application" and copy the code from there. Its a perfect example of what you are trying to do, but without the view switching (which you already seem to have done).

Br, Paul Peelen

Paul Peelen
hi paul,i edited my question. the only way to get these examples is by creating a new project and copying the code from there, right? how awful is that?
immuner
well, you don't have to copy the code if you don't want to. You can use the code as an example and create your own. But why re-inventing the wheel? Apple does have a very good example in that code which you can basically copy (and adapt to your preferences).
Paul Peelen
sure yes. my point was that i would expect when adding an xib file or a viewcontroller class to be able to select a template.
immuner
Ah, ok... sorry, missunderstood you. As far as I know... no template is available thru xcode.
Paul Peelen
A: 

I'm not sure, but from your question it seems as if you should go with a full navigation-based application. Start reading here. It will make it all a lot easier, e.g. no need for dealing with back buttons by yourself.

(by the way: TableViewS scroll on their own)

Kai
i am not sure that a full navigation-based app is what i need. parts of my app will need navigation. the issue mainly arises as to how i combine some different sets together.cheers for the tableview tip
immuner
+1  A: 

The one big mistake when i started to write to iphone was that i created NavContoller and Tab controller separately. always create just tab contoller and then configure in this tab controller navigation controller.

there is tutorial video how to do this http://www.youtube.com/watch?v=LBnPfAtswgw

sherilyn