I'm trying to add the ECSlidingViewController in my project, but I'm a novice on iOS and I'm not sure what to do in order to follow the instructions: "Add a UIViewController to your storyboards and set the subclass to ECSlidingViewController"
I've added the UIViewController, but now how do I set the subclass?
I don't use storyboards, but it sounds like you have to set custom class for this controller in identity inspector.
Suppose, you added an UIViewController in StoryBoard named "InitialSlidingViewController".
Then in InitialSlidingViewController.h, you should make the interface declaration as follows.
#interface InitialSlidingViewController : ECSlidingViewController
And please check the demo given by "ECSlidingViewController". You will understand it then.
I think you've got class and subclass the wrong way around.
What you are creating is a class called ECSlidingViewController that is a subclass of UIVIewController.
In you ECSlidingViewController.h you should have the following...
#interface ECSlidingViewController : UIViewController
This means you are defining a class called ECSlidingViewController and it is a subclass of UIViewController.
Related
In order to fix bug I need to change a UIViewController into a UITableViewController. Only thing is that the current viewController is a subclass of a base UIViewController. How can I inherit behavior from base? Creating a whole other BaseTableViewController sounds very redundant.
I have been going through this tutorial, "Option 2: Prototype Cells"
I implimented all the steps, but, the following code gives me an error:
#interface MTViewController : UITableViewController
#end
the error message is:
instantiated view controller with identifier "UIViewController-BYZ-38-t0r" from storyboard "Main", but didn't get a UITableView.'
Here is what I tried - I changed UITableViewController to UIViewController and the error went away. But, the tableview remains blank. Can you tell me why this is ?
In your storyboard, you need to make the root view of your UITableViewController a UITableView.
Try changing your super class to UIViewController or change the controller in your storyboard to TableView Controller
#interface MTViewController : UIViewController, UITableViewDataSource, UITableViewDelegate
#end
Drag a new instance of Table View Controller into your storyboard, copy the cells you created in your previous controller into the new one.
This error occurred probably because you used the default UIViewController created by XCode which isn't a UITableViewController.
I met exactly the same issue as you.
You're probably using a UIViewController instead of a UITableViewController in the storyboard.
NOTE:
Only subclass a custom UITableViewController in the storyboard is not enough. You'll see the difference:
difference between UIViewController and UITableViewController
So you have to drag out a UITableViewController from the library, then move all things(cells) to it. Don't forget to check bindings and auto layouts if broken.
And of course you cannot move the tableview to the root of UIViewController, it just doesn't work like that. =)
Actually you are using UIViewController not UITableViewController. Delete your default view controller and drag new TableViewController in your storyboard. Because your ViewController not having TableView, but it's trying to load cells.
Simple solution is : Delete ViewController and add TableViewController
Then you have to change its class name to MTViewController or Your Class Name
I've had this problem too. I created originally plain UIViewController then i decided to rather use UITableViewController. Problem is that i forgot to set storyboard ID on new controller, and change it to something else on the old controller, otherwise you will instantiate the old controller from storyboard and this problem will occur.
In the storyboard just change the class of your ViewController to your new class name which here is MTViewController - image of steps
make sure the dataSource is set to self.
I am writing a simple app with custom storyboards for iPhone and iPad. I have a generic viewcontroller class from which my custom iPhone and iPad viewcontrollers inherit. Outlets and IBActions in my storyboards are mostly wired up to the generic viewController class and everything works well.
Now for stylistic reasons I decided to make my iPhone's viewcontroller be a UITableViewController and it can no longer inherit from my generic viewcontroller. I've been googling and searching this site and see advice which says I should write a category and use this in my custom classes.
I have never done this, but I looked at the documentation and understand the concept, but once I move my code into a category, how would I be able to link my storyboard's outlets and actions (ctrl-drag from storyboard) to the methods which are now moved out of my custom viewcontroller classes? Usually I would for example ctrl-drag from a switch in the storyboard to an existing IBAction method in my generic viewController, but these methods will now be inherited and not showing my my custom classes to drag to.
I am just a hobbyist and newb, so I apologize if this question is too basic.
You can use UIViewController with UITableView instead of UITableViewController.
1.In storyboard, get a new UIViewController and linking with your custom viewcontroller class.After that,put an UITableView into that UIViewController and linking with that class using (ctrl-drag from storyboard) called mTableView
2.In that class you should implement <UITabBarControllerDelegate,UITableViewDataSource>.
Use mTableView instead of self.tableView just like in UITableViewController.
I'm going through an Xcode tutorial and it's asking me to create a UIViewControllersubclass file and then make it a subclass of UITableViewController.
I'm using Xcode 5.1.1 and I still cannot find the UIViewControllersubclass template in creating a new file.
Someone please tell me how to do this in the latest version of Xcode.
Here is the tutorial for reference https://www.youtube.com/watch?v=2p8Gctq62oU (21:15)
Thanks in Advance
In Xcode go to the File | New menu. Choose File. Under iOS choose Source then Cocoa Touch class. Then give the new class a name and choose UITableViewController for the subclass.
UITableViewController is a subclass of UIViewController, so when you create a new UITableViewController, it will be a subclass of both UITableViewController and UIViewController.
To create a subclass of UITableViewController in Xcode, either go to File -> New File, or hit command+n, select Cocoa Touch under iOS, and select the Objective-C class:
You will then be prompted with a window like below. Name your new class and select UITableViewController in the subclass drop-down box. This "NewTableViewController" will be a subclass of UITableViewController, which is already a subclass of UIViewController as described above.
I think your getting a little confused with what a subclass is. A UIViewController is not a subclass, subclass would be a UIView class or an NSObject, something you import into a view controller to handle different tasks.
You can import a UIViewController into another UIViewController or in your case a UITableView but then it becomes a child not a subclass.
To import a subclass you call the subclass using
MySubclassFile *subclass = [[MySubclassFile alloc] init];
then you can call a method from that subclass like so...
[subclass mySubclassMethod];
import a UIViewController as a child is a little more complex but still
MyViewController *childView = [self.storyboard instantiateViewControllerWithIdentifier:#"STORYBOARD_IDENTIFYER"];
childView.view.frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height);
[self addChildViewController:childView];
[self.view addSubview:childView.view];
I hope that helps :)
I want to change a TableViewController to a new UIViewController (PlayersViewController) from a UIViewController subclass, so I added two files (.h, .m), and then went back to the Identity Inspector/Custom Class.
Expected to find the PlayersViewController in the pulldown menu in Custom Class but could not find it, so I typed it in and hit "Return", but that didn't work either.
Am I doing something wrong?
Your new class should inherit from UITableViewController, not UIViewController. Only subclasses of the base class are available to select in the custom class field.