1

I'm trying to create a view that's going to have 3 separate tables on it, one on the left side and two on the right (one above the other). All three are going to use static cells. I tried setting this up using a normal View Controller, and dropping 3 Table Views into it, but when I switch them over to static cells, I get errors saying "Static table views are only valid when embedded in UITableViewController instances". If I try starting with a Table View Controller, it comes loaded with a full screen Table View, and I can't find a way to re-size it to only half the screen so I can get the other 2 Table Views I need onto the page.

I did find another post called several tableviews in one view when I was looking into this. One of the comments to the question mention that it is possible to add extra table views to a Table View Controller, but the post just says "it's hard", and doesn't elaborate any or provide a link, and I wasn't able to find any more about it.

At the same time, some of the answers in Combine static and prototype content in a table view say that it is not possible to have multiple Table Views in a Table View Controller, but once again, there is no supporting documentation as to how the poster knows that.

Does anyone know either:

  • how to add additional table views to a Table View Controller, or
  • a work around to the "Static table views are only valid when embedded in UITableViewController instances" error?
Community
  • 1
  • 1
GeneralMike
  • 2,951
  • 3
  • 28
  • 56
  • 1
    May be similar to your question .. http://stackoverflow.com/questions/8945728/how-to-visually-create-and-use-static-cells-in-a-uitableview-embedded-in-a-uivie – ila Aug 24 '12 at 19:32
  • Thanks for the link, looks like one of the ideas there are going to work for me. Kinda ashamed I wasn't able to find that one for myself, I was looking for something like that on here for quite a while. – GeneralMike Aug 25 '12 at 17:24

1 Answers1

2

Your approach has no point. Why don't you create different controllers to each of the tableviews?

I think you want to use one of the standard provided controller container (split-, navigation-, tabbarcontroll), and you want to add more nested tableview to one of the container. But what you really need is a custom controller container architecture. Check out WWDC 2011 'Implementing UIViewController Containment'. With this approach from iOS5 it is possible to arrange as many UITableView on the window as you want. It is fully customizable.

János
  • 32,867
  • 38
  • 193
  • 353
  • 1
    also see this SO Question: [How does View Controller Containment work in iOS 5?](http://stackoverflow.com/questions/8379759/how-does-view-controller-containment-work-in-ios-5) – Matthias Bauch Nov 15 '12 at 15:46
  • My customer requires all three tables to be visible at the same time (which means navigation & tabbar are out), so the point of my approach is giving my customer what they are asking for, instead of trying to tell them they aren't asking for the right thing =). Split controllers only have room for 2 views, so I'd still have to try to split one of those into 2 tableviews anyway, which would bring me to the same point I was at. – GeneralMike Nov 15 '12 at 17:25
  • I wasn't aware of the custom controller container method you mentioned, so thank you for that link, and I'll take a look at it. As it is, I ended up switching to prototype cells for this particular page, but the custom controller container may be something I will want to use in the future. – GeneralMike Nov 15 '12 at 17:27
  • With controller container you can create the same layout as splitview controller, but you can do much more. You can place 3 table out, you can nested them into navigationcontrollers one by one, or you can combine theme with UITabbarController. – János Nov 15 '12 at 18:40
  • Yeah, I was reading that in the the link @MatthiasBauch posted. I haven't had time to check out WWDC 2011 yet, but it looks promising. Thanks for the help. – GeneralMike Nov 15 '12 at 21:13
  • Could you accept it, if you think you are on the right track? ;) – János Nov 15 '12 at 21:45
  • I usually don't actually accept it until I put the code in and can verify it works, but since I'm not going to be looking at this again for a while probably I'll accept now. – GeneralMike Nov 16 '12 at 16:47
  • Thanks! Btw, I saw, you have a question relating fortran compilation to iOS / armv7. Can I ask, was is successful for you? Accidentally, I have a similar project. – János Nov 17 '12 at 00:36