开发者

Making 2 Separate App Delegates For Universal App?

开发者 https://www.devze.com 2023-03-26 14:48 出处:网络
Should I make 2 separate app delegates for a universal app?One myAppDelegate, then myAppDelegate_iPhone and myAppDelegate_iPad which are subclasses?Reason being iPhone should have IBOutlet of NavContr

Should I make 2 separate app delegates for a universal app? One myAppDelegate, then myAppDelegate_iPhone and myAppDelegate_iPad which are subclasses? Reason being iPhone should have IBOutlet of NavController while iPad should be UISplitViewController.

Also, how do I separate actions between iPhone and iPad. For example, a button on iphone may push a view, but on iPad i want to have a small window popup instead rather than a full-screen 开发者_如何学Cpush. Do I just use a if/else statement to check if iPad (by uiswitchviewcontroller), then go from there?

if (NSClassFromString(@"UISplitViewController") != nil && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        //currentDeviceType = iPad;
    }
    else {
        //currentDeviceType = iPhone;
    }


This question seems to be along similar lines.

Universal iPhone/iPad AppDelegate

This doc from Apple might also prove helpful.

Introduction to Universal Apps


No need to take two separate application delegates. You can code on the condition...

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){}

This will automatically detect the device.


To enable rotation on the device, you need to return YES to

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return YES;
}

FOR ALL OF YOUR VIEW CONTROLLERS.

You should also add your supported orientations to your plist or info under xcode 4.

Also keep in mind that stack overflow prefers that a new question be asked when the question topic changes :)

0

精彩评论

暂无评论...
验证码 换一张
取 消