PDA

View Full Version : How to create a dialog like Twitter in programming?




mikezang
Mar 9, 2012, 06:24 AM
I want to create a universal dialog both for iPhone/iPad in programming easily?
Does anyone give me a suggestion?



vultureboy
Mar 9, 2012, 10:40 AM
You'd have to make sure your app is Universal (of course) and this is how I load my credits modal dialog...


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!

mikezang
Mar 9, 2012, 10:53 AM
You'd have to make sure your app is Universal (of course) and this is how I load my credits modal dialog...


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?