Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-03-2010, 02:18 AM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 13
markkram is on a distinguished road
Default upgrading my iPhone app to iPad

Hi All,

I have a nice little iPhone app that is quite complex. I want to create a Universal application from it now, and I have read the articles on Apples site and many other basic tutorials, but after updating my app to work with iPad, I would like to be able to choose which NIB file to load on each screen (im using a tab controller).

Can I do this? Ideally, I would like to create two NIB files for each view but keep the view controller the same, for example:

PeopleViewController.xib
PeopleViewController-ipad.xib
PeopleViewController.m
PeopleViewController.h

and when the view controller is created, check which device you are on, then choose the correct NIB to load.

Can this be done??

Thanks a lot for any help you can give
markkram is offline   Reply With Quote
Old 09-03-2010, 10:04 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

I'd say it's possible -- here is my first idea:

UIViewController has an initWithNibName: bundle: method that you can override

You can override it, check which device you're running, then load up the proper xib instead

Code:
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle
{
       if( //check for iphone is true )
       {
           self = [super initWithNibName:@"PeopleViewController" bundle:nibBundle];
       }
       else if( //check for ipad is true )
       {
           self = [super initWithNibName:@"PeopleViewController-ipad" bundle:nibBundle];
       }
       else self = [super initWithNibName:nibName bundle:nibBundle];

        //do any other setup
       return self;
}
smithdale87 is offline   Reply With Quote
Old 09-07-2010, 05:59 PM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 13
markkram is on a distinguished road
Default

thanks for that smithdale87, sorry I didnt reply sooner, i dont seem to be getting the notifications on these forums.

I tried to implement this, but the method never seems to get called.

I have a tabbarcontroller which, as its fisrt tab, has my PeopleViewController (which is a UIViewController). I put it the method, but it never gets called... is there something else I need to do?
markkram is offline   Reply With Quote
Old 09-07-2010, 11:54 PM   #4 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 13
markkram is on a distinguished road
Default

Ok, I have found out how to do it...

1. Update your target to be a single universal application
2. Make note of the new XIB file XXX-iPad.xib that xcode creates for you
3. Create new XIB files that correspond to your iPad application (you can create new XIB files that point to your existing UIViewController's, just add a single "View XIB", change its class to your existing view controller)
4. Inside that XIB file, change the normal XIB files that load to point to the new XIB files you made in step 3
5. Connect up your IBOutlet's like you would normally in your new XIB
6. ???
7. Profit

Easy once you know how
markkram is offline   Reply With Quote
Old 12-12-2010, 02:08 PM   #5 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 14
drewbert is on a distinguished road
Default

Quote:
Originally Posted by markkram View Post
Ok, I have found out how to do it...

1. Update your target to be a single universal application
2. Make note of the new XIB file XXX-iPad.xib that xcode creates for you
3. Create new XIB files that correspond to your iPad application (you can create new XIB files that point to your existing UIViewController's, just add a single "View XIB", change its class to your existing view controller)
4. Inside that XIB file, change the normal XIB files that load to point to the new XIB files you made in step 3
5. Connect up your IBOutlet's like you would normally in your new XIB
6. ???
7. Profit

Easy once you know how
So let's say I have a tableview flow that I'd like to include in a SplitView on the iPad version of the universal app. How do I do this? There's no longer a one-to-one correspondence between viewcontrollers and nibs. Is there any way to detect between iPhone and iPad and deliver accordingly?

Thanks,
Drew
drewbert is offline   Reply With Quote
Reply

Bookmarks

Tags
best-practice, ipad, iphone, view

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 338
11 members and 327 guests
bignoggins, carlandrews, flamingliquid, ilmman, iram91419, linkmx, nadav@webtview.com, Objective Zero, Paul Slocum, stanny, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,656
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, iram91419
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:44 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0