Dynamically load nib for iPhone/iPad within view controller

前端 未结 5 2102
悲哀的现实
悲哀的现实 2020-12-24 13:30

I have converted an iPhone application using the wizard like thing in XCode into a universal app.

It builds fine but obviously looks a bit rubbish in some areas :)<

5条回答
  •  难免孤独
    2020-12-24 14:19

    I just put these two methods in a class called IPadHelper, and use the addIPadSuffixWhenOnIPad method to conditionally pick between two nibs depending on platform

    + (BOOL)isIPad{
        if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iPhoneOS_3_2){
            if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
                return YES;
            }
        }
        return NO;
    }
    
    + (NSString *)addIPadSuffixWhenOnIPad:(NSString *)resourceName{
        if([IPadHelper isIPad]){
            return [resourceName stringByAppendingString:@"-iPad"];
        }
        else {
            return resourceName;
        }   
    }
    

    see here http://cocoawithlove.com/2010/07/tips-tricks-for-conditional-ios3-ios32.html for more explanation of the first method...

提交回复
热议问题