سؤال

In my storyboard, I have created a new UITableViewController object for which I would like to specify some custom code. I created a new controller with the following header:

@interface CustomController : UITableViewController

When I select the UITableViewController in the Storyboard view and navigate to the Identity Inspector, I can see my CustomController in the Custom Class drop-down. However, when I select it, I hear an error sound, which is referred to as "Morse" in the system preferences.

When I deselect the UITableViewController and re-select it, it has cleared my CustomController selection and replaced it with UITableViewController. I do not understand why XCode does not accept this, as from my understanding, this is all that is required to add your own code to a UITableViewController. I am not sure if I have encountered an XCode bug or if I have configured my class incorrectly.

هل كانت مفيدة؟

المحلول

It is possible to use a UIViewController as a UITableViewController, but you have to do some work. If you "convert" a UIViewController to a UITableViewController, you'll need to implement the UITableViewDelegate and UITableViewDatasource protocols. You may also need to provide an outlet for a UITableView. You'll also need to handle keyboard events. Basically a bunch of effort for not much return. Probably best in your case to start fresh with a new UIViewController class inheritted from UITableViewController.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top