0

Please help me, I never made universal UIViewControllers with xib for iPhone/iPad. How I can create class with .m and .h files and _iphone.xib and _ipad.xib?

I was try to create xib manually and create outlets for view, but after pushing this controller I had uncaught error:

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "FullNewsViewController" nib but the view outlet was not set.

Thanks!

Alexander Zakatnov
  • 1,646
  • 1
  • 15
  • 16

3 Answers3

2

The problem, what I can see from the error you posted, is that you have not set the owner properties of the NIB correctly.

Your nib files does not seem to have the correct file's owner and thus can't set the view on the view controller.

Open the nib, and go to File's Owner in the left since of the screen. Set the Custom Class property to the class of your viewController. The right click on the File's Owner again and drag the view property to your view.

rckoenes
  • 69,092
  • 8
  • 134
  • 166
1

You should follow Apple iOS App Programming Guide

Creating a Universal App

Here you will get some tips, how to create Universal Application.

Hope this will help you out.

Kamleshwar
  • 2,967
  • 1
  • 25
  • 27
0

REview this link may be helped you...

http://elusiveapps.com/blog/2011/10/converting-iphone-apps-to-univeral-ipad/

if the view controller can easily be used for both ....

MyViewController.h
MyViewController.m
MyViewController~ipad.xib
MyViewController~iphone.xib

Set the File's Owner in both the xib files to your UIViewController subclass and connect up the view + anything else you want connected.

When I init my view controller this is all that's required

MyViewController *viewController = [[MyViewController alloc] init];
// OR
MyViewController *viewController = [[MyViewController alloc] initWithNibName:nil bundle:nil];

The Apple docs for UIViewController state that if you provide a xib with the same name as the view controller it will be loaded. The ~ipad and ~iphone ensure that the correct xib is loaded.

Vikas S Singh
  • 1,748
  • 1
  • 14
  • 29