Application Types
Native iPhone Applications:
- based on Cocoa Touch
- written in Objective-C
iPhone Web-based Apps:
- Website optimized for iPhone
- written in HTML, CSS, JavaScript(, PHP)
- usable as App via "WebClip"
Hybrid Applications:
- mixed Cocoa Touch & Web App
Application Styles
Apples Human Interface Guidlines beschreiben drei mögliche Stile für Applikationen:
Productivity Apps
- Hierarchical Info
- Usually UITableView
- extremely consistent with HIG
- eg. Mail
Utility Apps
- Specific info with as little interaction as possible
- Usually using the small "i" to flip views
- neater Design (eg. custom TableRows)
- nevertheless very consistent with HIG
- eg. Weather
Immersive Apps
- Custom Interface
- low inforcement of Apple's HIG
- eg. Racing Game
Drawing Methods
Es gibt drei gundsätzlich verschiedene Methoden, um den "Anzeige-Part" in einer iPhone App darzustellen.
UIViews
- Gewöhnliche Komponenten, die in Interface Builder arrangiert werden
- z.B. UITableView, UIWebView, UIButtons, UITextField, UISlider, UIPickerView ...
Beispiel (UITableView subclass):
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// In order to show a new view, we'll create a new view controller instance
// and push it onto the views stack of the Navigation Controller
RecipeDetailViewController *detailViewController =
[[RecipeDetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:detailViewController animated:animated];
[detailViewController release];
}
Quartz 2D
- Einfaches, zweidimensionales Zeichnen
- Painting-on-Canvas Methode: übereinanderlagern durch Position im Quellcode
- iPhone Dev Center: Quartz 2D Programming Guide
Beispiel (UIView sublcass):
- (void)drawRect:(NSRect)rect {
CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort];
// ********** Your drawing code here **********
CGContextSetRGBFillColor (myContext, 1, 0, 0, 1);
CGContextFillRect (myContext, CGRectMake (0, 0, 200, 100 ));
CGContextSetRGBFillColor (myContext, 0, 0, 1, .5);
CGContextFillRect (myContext, CGRectMake (0, 0, 100, 200));
}
Open GL
- Komplexes, dreidimensionale Strukturen
- Standartisierte OpenGL Sprache (Subset für iPhone)
- iPhone Dev Center: OpenGL ES Programming Guide
Beispiel (UIView subclass w. custom timer):
- (void) render {
[EAGLContext setCurrentContext:context];
glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
glViewport(0, 0, backingWidth, backingHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, (GLfloat)(sinf(transY)/2.0f), 0.0f);
transY += 0.075f;
glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glVertexPointer(2, GL_FLOAT, 0, squareVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}
-(void)applicationDidFinishLaunching:(UIApplication*)application {
// (...)
animationTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)((1.0 / 60.0) * animationFrameInterval)
target:self
selector:@selector(render)
userInfo:nil
repeats:TRUE];
}
Diese Seite ist Teil des Werkmoduls iOS Development von Michael Markert für Interface Design / Fakultät Medien an der Bauhaus-Universität Weimar.