Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing UITableViewCell Nib inside a UITableView inside a UIViewController
    primarykey
    data
    text
    <p>I've been looking for a solution to this question for a few hours now, and I can't seem to figure out a way to construct a UITableViewCell in Interface Builder, link its actions to a parent UINavigationController, and then use the cell for displaying information across two separate instances of UITableViews. After a few hours of research, I have structured my files as such:</p> <ol> <li><p>UIViewController, NOT created in Interface Builder, that is my base view for the entire project. Contains an IBAction that pushes the UserInfoController on the stack.</p></li> <li><p>UITableViewCell, created in Interface Builder, which contains a button that when pressed should push a new UIViewController, let's call it UserInfoController, on top of the stack. The File's Owner is the above UIViewController.</p></li> <li><p>UIView, created in Interface Builder, that I use in the above UIViewController. This UIView contains a top UIView section with data and a bottom UITableView that displays the UITableViewCells. I want to make it so that when you press the button in the UITableViewCell, displayed in this UIView, it activates an action in the parent UIViewController.</p></li> </ol> <p>I feel like I'm missing something big here. I would also like to eventually create another UIViewController with a UIView and UITableView that should ALSO use the UITableViewCell and perform the action of the first UIViewController. However, since I can't even get this working for one of my views, I'll wait until I figure the above problem out.</p> <p>EDIT: My gut instinct is telling me that this is a problem with an Outlet. Currently, my UIViewController is acting as the File's Owner to the UIView which contains the UITableView. The UIView also contains the code for the UITableViewDelegate and the UITableViewDataSource, which uses my UITableViewCell to display relevant information. The UITableViewCell is its own Nib, but its File's Owner is ALSO the UIViewController. However, when I go to press the button inside my UITableViewCell, the event registers with the UIView, despite the fact that there are no outlets there. The reason why I want the UITableViewCell to be its own Nib is because I want to re-use it for other UIViewController views later on.</p> <p>I can view the UITableViewCell just fine, but I cannot get it to behave properly. How can I link the action of the button within my UITableViewCell not to the file containing its UITableView Delegate and DataSource, but to the UIViewController that contains it?</p> <p>Hope this is a little bit more clear :-D</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COIt's not entirely clear what your question is. You can't get a UITableViewCell to use a custom cell? Or you can but the actions don't work? Or you can but the actions don't work and also the cell doesn't update? Or it does work but not when you have two instances? Or the table doesn't use the custom cell and therefore the actions dont work, the cell doesn't update and adding another table instance doesn't help. Tackle one thing at a time. When you get the custom cell working it should be relatively easy to use a cell from a nib. Then tackle the action chain.
      singulars
    2. COSo what's your question? What have you tried? What works? What doesn't?
      singulars
    3. COSo, right now, the hierarchy looks like this: UIViewController->UIView->UITableView->UITableVIewCell. I made the file owner of the UITableViewCell the UIViewController, but when I press the button on my custom cell, the UIView is called to perform the action - not the UIViewController. One reason I think this is happening is because I have to link an outlet on the UITableCellView to the UITableView's parent UIView in order to edit any of the properties. If I get rid of this outlet and instead place it in the UIViewController, the UIView cannot find my UITableViewCell
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload