Re: How to Instantiate a Table View in existing View?
Re: How to Instantiate a Table View in existing View?
- Subject: Re: How to Instantiate a Table View in existing View?
- From: Matt Neuburg <email@hidden>
- Date: Sun, 21 Mar 2010 09:17:04 -0700
- Thread-topic: How to Instantiate a Table View in existing View?
On Thu, 18 Mar 2010 22:51:22 +0000, Dave <email@hidden> said:
>I have an App with a View Controller with one button on it.
A view controller is not interface so it can't contain a button. It is
therefore unclear from your words what it is you've got. Do you mean a
navigation bar? Do you mean you've just got a window that you dragged a
button into? What?
>I created
>a new Table View by selecting New File in XCode and selecting a
>UIViewController subclass, I select the "UITableViewController
>subclass" and "With XIB for user interface" options. This creates a
>new .h, .m and .xib file. My question is now what?
So now what you've asked for is a table view controller subclass plus a
corresponding nib that it owns. Your code can now work with that table view
controller subclass just as it would with any view controller subclass. For
example, if you've got a navigation controller, you can push the table view
controller onto its stack of view controllers: the table view controller
will load its nib, and the table view will appear in the navigation
interface. That might be what you're after here. Or not.
>In my existing
>View controller I have one button and I want to add the TableView so
>it appears beneath the button.
You're going to need to read the View Controller Programming Guide and the
Table View Programming Guide, and use correct terminology for things, both
in your mind and in asking questions.
Here are a couple of things to be aware of (these caught me in first couple
of days programming for iPhone - then everything fell into place):
* The nib templates are not necessarily the best way to make interface. They
fit only some very basic situations. It is often simpler to create your own
view, either in a nib or in code. This is as true of a table view as of any
other interface item - in Interface Builder you can just drag a table view
into a view.
* You don't need UITableViewController subclass in order to work with a
table.
For example, take a quick look at my TidBITS News app (it's free). The
opening view is a table view within larger view that also contains label
(telling when the app's cache was last updated), which itself appears in a
navigation interface. I never use a UITableViewController. (On the *first*
day of writing that app, I did exactly what you did, because the template
looked like a simple solution, but then I realized I had merely bolluxed
myself and limited my options, so I scrapped that and started over.)
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden