This slideshow introduces some basic suggestions and design patterns for creating a Universal application (iPhone and iPad) under iOS.
Presented originally on September 29, 2010 at the Vancouver Island iOS Developers' Group.
3. Intended Audience
1. You understand Objective-C
2. You have created working iOS Apps before
3. You are familiar with the XCode environment
4. You have used Interface Builder
If this does not describe you, not to worry. As long as you
have a good understand of C++, Java, or another related
language you should be able to understand the examples.
4. Basic Steps
1. Configure Project Settings
2. Create Your Classes
3. Test
4. Configure Icons
5. Submit
5. Key Project Settings
Always use latest SDK...
...but target oldest OS
Project settings
Application .plist file
7. Initial XIB file
Shared or separate App Delegate?
It’s up to you.
8. Coding Tools
CHECK CLASS SUPPORT
Class notificationClass = NSClassFromString(@"UILocalNotification");
if (notificationClass) {
UILocalNotification* n = [[notificationClass alloc] init];
}
CHECK METHOD SUPPORT
if ([UIApplication
instancesRespondToSelector:@selector(scheduleLocalNotification:)]) {
[[UIApplication sharedApplication] scheduleLocalNotification:n];
}
CHECK DEVICE
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// This is a great new Macro in recent SDKs
}
9. Coding Tools
CHECK FOR RETINA DISPLAY
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] &&
[[UIScreen mainScreen] scale] == 2.0) {
// do iPhone 4 stuff
}
18. 4. UIWebView for unique presentation
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
/* rules for iPad */
body {
font-size: 24px;
}
img.LGautosize {
width: 36px; height: 36px;
}
img.SMautosize {
width: 24px; height: 24px;
}
}
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
/* iPhone rules here */
body {
font-size: 16px;
}
img.LGautosize {
width: 24px; height: 24px;
}
img.SMautosize {
width: 16px; height: 16px;
}
}
19. 4. UIWebView for unique presentation
<img src="heart.png" class="LGautosize"/>
20. 5. Unique Subclasses
•Use Subclasses instead of conditionals
•Common behavior in parent class
•Use XIB to create proper subclass
•Device specific behavior in subclass