iPhone simulator shows black screen when setting a custom UIViewController class - iphone

When creating a single view application in Xcode and dragging a UIButton in, for example, the button shows up when running the application in the iPhone simulator. However, when creating a new UIViewController class and setting that as the custom class of the view controller in the storyboard file, just a black screen is shown in the iPhone Simulator.
What did I do wrong?

I bet the Xcode template included the loadView method in your controller class. You need to delete that as you only override that method when you are creating your interface via code.

Related

Copied iPhone storyboard over to iPad, but iPad loading with different view controller

I recently copied everything in my iPhone storyboard over to an iPad storyboard and changed nothing. It runs perfectly on the iPhone, loading WelcomeViewController as the initial scene.
However, when I run it on the iPad, the program crashes because it tries to load MainViewController as the initial scene.
I checked on Interface Builder, and the initial scene is set to view controller WelcomeViewController. I went in the debugger and put a breakpoint in the ViewDidLoad method of WelcomeViewController, and the iPad never hits that breakpoint but the iPhone does.
This is the Identity Inspector for the view controller of my initial scene.
This is the Attributes Inspector for the view controller of my initial scene (same as above).
Why does the iPad insist on trying to load ViewController as the initial view controller?
Thanks
EDIT: When I go to Targets > iPad Deployment Info, and set the main storyboard to the MainStoryboard_iPhone instead of MainStoryboard_iPad everything works. For some reason this MainStoryboard_iPad, a literal clone of the iPhone storyboard, doesn't.
Make sure your iPad view has initial controller set to WelcomeViewController in the storyboard. It is represented by an arrow as given below.
Next make sure your iPad Deployment section in target refers to your iPad storyboard.

UIButton not showing on simulator when view's class is TPKeyboardAvoidingScrollView

I have this weird problem where the buttons on the simulator or my iPhone are not showing when the class of the view's set to TPKeyboardAvoidingScrollView.
Here's a screenshot:
When the view's class is set to UIView (default) it works properly.
See this post for instructions.
For non-UITableViewControllers, use it as-is by dropping the TPKeyboardAvoidingScrollView source files into your project, popping a UIScrollView into your view controller’s xib, setting the class to TPKeyboardAvoidingScrollView, and putting all your controls within that scroll view.
To use it with UITableViewController, pop the TPKeyboardAvoidingTableView source files in, and just make your UITableView a TPKeyboardAvoidingTableView in the xib — everything should be taken care of.
Are you using it with or without a UITableViewController? Make sure you've embedded the button in your UIScrollView. The site linked above also has a sample project you could reference for more help.

IPhone Storyboard - Assigning class to view controller in storyboard

I have created a simple app using storyboard. In storyboard file, i have dragged one view controller. I want to assign a class to the newly added view controller. To do this, I clicked on new file in Xcode, clicked on Objective c class, entered class name MyViewController and subclass is of UIViewController. I went back to storyboard and clicked on Custom class type and given MyViewController in class tab. But it is not taking this. If i unselect the viewcontroller and select, custom class shows "UIView" again.
I am using Xcode version 4.3.3 (4E3002).
xcode does this problem even if everything is fine. Close your xcode project and then quit xcode. Start again and you will be able to find the class in the dropdown menu.

How to launch a window.xib file in storyboard?

I'm new to Xcode and building my first App, I want to incorporate a Twitter feed, my project is done in Storyboard but the Twitter feed code is with .xib, is there a good way to launch the .xib in Storyboard?
There is no real need to launch the window.xib in the storyboard. Just instantiate your view controller that is the file owner of your twitter feed code programmatically and push into your navigation controller. It won't cause any problems. The storyboard is basically an extension to the way screens were managed before. You can have all you "scenes" in storyboard and programmatically push a view controller from outside the storyboard without any problems and navigate back again.
The UINavigationController is the key. It only cares that it got a UIViewController.

Universal app design 1 table view that opens different view on cell click depending if on iPad or iPhone

I'm making a universal app and I've run across a situation I'm stumped on. On the iPad I'm using a split view, and I would like to make a UITableViewController that is shared on both the iPad and iPhone. I did that, but now when the user clicks a table cell I need to respond. On the iPhone I will init a new view controller and push it in the UINavigationController stack, but on the iPad I will init a different UIViewController and display it in the detail view pane. I know how to do each of these actions by its self, but how do I write the UITableViewController so that it knows which action to preform depending if its the iPhone or iPad?
Is there a better way to handle this?
Here's what I did in that exact same situation.
The table-view controller had a property called detailViewController. If this property is not nil than I updated that view based on what cell was touched. If that property was nil I must be on the iPhone and inside a UINavigationViewController. I use self.navigationController to push my new iPhone view.