Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikezang

macrumors 6502a
Original poster
May 22, 2010
930
38
Tokyo, Japan
I want to create a universal dialog both for iPhone/iPad in programming easily?
Does anyone give me a suggestion?
 

Attachments

  • IMG_0127.jpg
    IMG_0127.jpg
    100 KB · Views: 130
  • IMG_0047.jpg
    IMG_0047.jpg
    102.7 KB · Views: 143
You'd have to make sure your app is Universal (of course) and this is how I load my credits modal dialog...

Code:
    BOOL deviceIsPad = (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone);
    
    AppCredits *appCredits = nil;
    
    if (deviceIsPad) {
        appCredits = [[AppCredits alloc] initWithNibName:@"AppCredits_iPad" bundle:nil];
        [appCredits setModalPresentationStyle:UIModalPresentationFormSheet];
    } else {
        appCredits = [[AppCredits alloc] initWithNibName:@"AppCredits_iPhone" bundle:nil];
    }
    
    [self presentModalViewController:appCredits animated:YES];

This shows the modal view full screen on the iPhone and in a smaller Presentation Form Sheet on the iPad.

Hope that helps!
 
You'd have to make sure your app is Universal (of course) and this is how I load my credits modal dialog...

Code:
    BOOL deviceIsPad = (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone);
    
    AppCredits *appCredits = nil;
    
    if (deviceIsPad) {
        appCredits = [[AppCredits alloc] initWithNibName:@"AppCredits_iPad" bundle:nil];
        [appCredits setModalPresentationStyle:UIModalPresentationFormSheet];
    } else {
        appCredits = [[AppCredits alloc] initWithNibName:@"AppCredits_iPhone" bundle:nil];
    }
    
    [self presentModalViewController:appCredits animated:YES];

This shows the modal view full screen on the iPhone and in a smaller Presentation Form Sheet on the iPad.

Hope that helps!
Thanks for your suggestion, so I have to create two xib files in Storyboard, is it true? is there any template so that it looks like what in pictures?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.