Can you add a UITableViewController's TableView to another View?
Posted
by Dan Harrelson
on Stack Overflow
See other posts from Stack Overflow
or by Dan Harrelson
Published on 2009-07-02T03:58:33Z
Indexed on
2010/04/03
8:13 UTC
Read the original article
Hit count: 483
I've inserted a UITableViewController and it's corresponding UITableView into a simple IB document. The goal is to include the UITableView inside of a parent UIWindow (or UIView) with other "stuff" (anything really) adorning the table. Here's what that might look like in Interface Builder.
http://danharrelson.com/images/skitch/iphone-tableview-3-20090701-205535.png
I've tried this numerous times and always get to the same place.
- Build a working subclass of UITableViewController filled with data
- Customize the UTableView and it's cells including tap targets
- Add the newly created UITableViewController into an IB document
- Drag the UITableView out of the UITableViewController and into the main UIView
- Wire up the UITableViewController to the UITableView
- Note: adding the UITableViewController in code results in the same problem
When running the app in the iPhone emulator or on a device the table displays correctly, but crashes the first time you try and interact with it. A scroll, a tap, anything crashes the app. This seems to be a delegate problem, like the UITableView doesn't know how to communicate back to the UITableViewController, but I have no idea how to correct the problem.
So far I have been able to get by by customizing the tableHeaderView to get layouts that suffice, but I'd really prefer to have the other technique work.
© Stack Overflow or respective owner