Do you use the nib file to customize the user interface of your view? The code you have really loads and initializes the ViewController. But then you will need to add some user interface elements to your view and present this view controller in your application. If you are using the nib file for your user interface, you want:
MainViewController *controller = [[MainViewController alloc] initWithNibName:@"nibFileName" bundle:nil];
This will connect your controller with the nib file. If you are not using the nib file, you need to programmatically add each element that you want to display.
After your view is configured, you need to present the view controller by adding it as a subtask to the current view or using the navigationController to click on the new viewController. You should be more specific about what exactly you are trying to do.
source share