Application Types: Difference between revisions

From Medien Wiki
Line 46: Line 46:
=== UIViews ===
=== UIViews ===
* Gewöhnliche Komponenten, die in Interface Builder arrangiert werden
* Gewöhnliche Komponenten, die in Interface Builder arrangiert werden
* z.B. UITableView, UIButtons, UITextField, UISlider, UIPickerView ...
* z.B. UITableView, UIWebView, UIButtons, UITextField, UISlider, UIPickerView ...


Beispiel:
Beispiel (UITableView subclass):
<source lang="objc">
<source lang="objc">
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     // Create a detail view controller, set receipe, then push it
     // 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];
     RecipeDetailViewController *detailViewController = [[RecipeDetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
    detailViewController.recipe = (Recipe *)[fetchedResultsController objectAtIndexPath:indexPath];   
     [self.navigationController pushViewController:detailViewController animated:animated];
     [self.navigationController pushViewController:detailViewController animated:animated];
     [detailViewController release];
     [detailViewController release];
Line 67: Line 67:
* [http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/index.html iPhone Dev Center: Quartz 2D Programming Guide]
* [http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/index.html iPhone Dev Center: Quartz 2D Programming Guide]


Beispiel:
Beispiel (UIView sublcass):
 
<source lang="objc">
<source lang="objc">
- (void)drawRect:(NSRect)rect {
- (void)drawRect:(NSRect)rect {
Line 89: Line 88:
* [http://developer.apple.com/iphone/library/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/Introduction/Introduction.html iPhone Dev Center: OpenGL ES Programming Guide]
* [http://developer.apple.com/iphone/library/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/Introduction/Introduction.html iPhone Dev Center: OpenGL ES Programming Guide]


Beispiel:
Beispiel (UIView subclass w. custom timer):
 
<source lang="objc">
<source lang="objc">
- (void) render {
- (void) render {
Line 117: Line 115:
     glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
     glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
     [context presentRenderbuffer:GL_RENDERBUFFER_OES];
     [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];
}
}
</source>  
</source>  

Revision as of 02:16, 7 March 2010

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

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

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.