7

I am an Objective-C beginner and I am going through the tutorial to create an IOS app using Apple developer articles.

https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/SecondTutorial.html#//apple_ref/doc/uid/TP40011343-CH8-SW1

I have created an unwind segue and I have gotten stuck. I have gone through SO posts such as given below

  1. StoryBoard issue in Xcode 6.1
  2. Change a UIViewController to a UITableViewController inside a storyboard?
  3. Want to create a cool static UI but : "Static table views are only valid..."

I tried to modify the story board source to use "tableViewController" instead of "viewController", but the storyboard won't open.

I am sure that there is an easy solution, but I don't know enough Objective-C or IOS development to know what it is, or how to implement it.

I have my controller implementing UITableViewController and my view as UITableView. I have attached the screenshot below.

XCode Storyboard setup

and the error message:

Error message and description

My source for ToDoListTableViewController.h is given below:

 #import <UIKit/UIKit.h>

@interface ToDoListTableViewController : UITableViewController

- (IBAction)unwindToList:(UIStoryboardSegue *)segue;

@end

and the implementation

#import "ToDoListTableViewController.h"

@interface ToDoListTableViewController ()

@end

@implementation ToDoListTableViewController

 . . . Other methods 

- (IBAction)unwindToList:(UIStoryboardSegue *)segue {
}
@end
halfer
  • 19,824
  • 17
  • 99
  • 186
Kartik
  • 2,541
  • 2
  • 37
  • 59
  • do not modify storyboard as source file unless you are sure what you are doing. As Duncan suggests, just drag and drop `UITableViewController` to your storyboard – Azat Mar 07 '15 at 07:40
  • @Azat I did that. If you see the screenshot http://i.stack.imgur.com/odrhd.png, the highlighted section is an implementation of UITableViewController. This is as per instructions from https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/SecondTutorial.html#//apple_ref/doc/uid/TP40011343-CH8-SW1. Thank you. – Kartik Mar 09 '15 at 20:59
  • have you solved your issue? – Azat Mar 09 '15 at 21:07
  • No. I have not been able to. I have a UITableViewController implementation as my controller class. See source code in the question. – Kartik Mar 10 '15 at 03:54
  • I don't know what happened. I started the story board process again and I was able to fix this issue. Not sure what happened. I am as clear as mud now. – Kartik Mar 14 '15 at 11:58

1 Answers1

8

Your picture is kind of small so it's a bit hard to tell what we're looking at. Plus your descriptions are a bit vague.

The deal is that in order to set up a table view as a static table view, it must be managed by a UITableViewController, not a regular UIViewController.

A UITableViewController is a special subclass of UIViewController. When you go to add a new scene to your storyboard, you go to the list of UI objects, find the UITableViewController, and drag one onto the storyboard.

An annoying thing about UITableViewController objects is that the ONLY thing they manage is a table view. You can't use them to set up labels, buttons, and other UI elements. Just a table view and nothing else.

You said:

'I tried to modify the story board source to use "tableViewController" instead of "viewController"...'

I have no idea what that means. What is a "story board source"? You don't "Modify the storyboard source", you drag a UITableViewController onto your storyboard.

Then you said "...but the storyboard won't open." I also don't know what that means. You're going to have to explain that.

Luckily, there is an easy solution to this.

What you want to do is to create a regular UIViewController to manage everything but the table view, and then put a "Container View" in that view controller and set up an "embed segue" that installs a UITableViewController inside that container view.

Here's how you do that:

Search in the list of UI elements on the right side for "container". Drag a container view onto your view controller where you want your table view to appear. Then drag a UITableViewController onto a blank space on your storyboard to create a new storyboard scene. Then control-drag from the container view in your first view controller onto the UITableViewController. This creates an embed segue, which causes the UITableViewController to be loaded as a child view controller with its view inside and sized to fit in the container view.

Now you can have a window that has both a table view managed by a UITableViewController AND other contents.

There are more details to setting this up that are beyond the scope of a SO post. I suggest you do some googling on container views and embed segues and try to find a tutorial on setting them up.

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • Hi, Duncan, SO creates a smaller image size of my actual images on display. There are high resolution images: 1. Storyboard: http://i.stack.imgur.com/odrhd.png 2. Error Message: http://i.stack.imgur.com/fpB58.png In the first image, you can see that TableView is managed by an implementation of UITableViewController called "ToDoListTableViewController". The source is given in the question itself. With regards to storyboard manipulation, I meant to refer to this. http://stackoverflow.com/a/22918268/300327 – Kartik Mar 07 '15 at 01:12
  • @Duncan Do you have the version for this tutorial in Swift too? http://iphonedevsdk.com/forum/iphone-sdk-tutorials/111816-using-static-table-views-in-ios-6-using-embed-segues.html . Many thanks – bibscy Mar 05 '17 at 21:43
  • @bibscy, no, I haven't rewritten that project in Swift. It's not that complicated, though, and the storyboard part is language-independent. – Duncan C Mar 06 '17 at 00:55
  • @DuncanC I have a question related to this topic http://stackoverflow.com/questions/42600534/ I'd very much appreciate your help. – bibscy Mar 08 '17 at 22:31
  • thank a lot . you saved my time . I did your command and success . here is so important >>> "Search in the list of UI elements on the right side for "container". Drag a container view onto your view controller where you want your table view to appear..........." – Erhan Demirci Aug 28 '23 at 11:38