Carl Mangold

Flash & iPhone coding & concepting
  • Home
  • Bright.app
  • Commentaar
  • iPhone
  • Nieuws
  • Obj-C tips

Categorie ’Obj-C tips’

3 Nov 2009

Tip: iPhone apps bouwen met HTML/CSS/JavaScript

orlyOké, het is geen Obj-C. Maar toch bijzonder interessant:

iPhone’s Safari webbrowser ondersteunt HTML5, en biedt daardoor veel meer mogelijkheden dan wat je van Microsoft’s Internet Explorer gewend bent. Denk bijvoorbeeld aan CSS animaties, 3D weergave-mogelijkheden en client side databases.

In Jonathan Stark’s boek Building iPhone Apps with HTML, CSS and JavaScript lees je er vanalles over. Compleet met voorbeelden.

Carl Mangold, 22:37 3 november, 2009

Labels: css, html, iPhone, javascript
Categorie: Obj-C tips, iPhone | Geen reacties »

21 Okt 2009

Tip: Google Analytics in je iPhone app

Je kent ongetwijfeld Google Analytics voor websites. Maar wist je ook dat je precies diezelfde analytics tegenwoordig ook bijzonder eenvoudig in je iPhone apps kunt integreren?

GANTracker.h
  1. //=== Initialiseer Google Analytics in je AppDelegate:
  2.  
  3. #import "GANTracker.h"
  4.  
  5. - (void)applicationDidFinishLaunching:(UIApplication *)application
  6. {
  7. //--- Google Analytics
  8.  
  9. [[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-12345678-1"
  10. dispatchPeriod:10
  11. delegate:nil];
  12. ...
  13. }
  14.  
  15. //=== En track de pageviews in je ViewControllers:
  16.  
  17. - (void)viewDidAppear:(BOOL)animated
  18. {
  19. //--- Google Analytics
  20.  
  21. NSError *error;
  22. [[GANTracker sharedTracker] trackPageview:@"NaamVanPagina" withError:&error];
  23.  
  24. ...
  25. }

Meer info: Google Analytics voor iPhone apps

Carl Mangold, 13:56 21 oktober, 2009

Labels: iPhone, obj-c tip
Categorie: Obj-C tips, iPhone | Geen reacties »

5 Okt 2009

Tip: UINavigationBar met achtergrondafbeelding

Als je de navigatiebalk bovenin je app wilt ‘branden’ met een eigen achtergrond, kun je dat ‘t handigst met een categorie-extensie op de UINavigationBar doen:

UINavigationBar BackgroundImage
  1. // UINavigationBarBackgroundImage.h
  2.  
  3. @interface UINavigationBar (BackgroundImage)
  4. @end
  5.  
  6. // UINavigationBarBackgroundImage.m
  7.  
  8. #import "UINavigationBarBackgroundImage.h"
  9.  
  10. @implementation UINavigationBar (BackgroundImage)
  11.  
  12. - (void)drawRect:(CGRect)rect
  13. {
  14. [[UIImage imageNamed:@"navBarBackground.png"] drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
  15. }
  16.  
  17. @end

Carl Mangold, 9:08 5 oktober, 2009

Labels: iPhone, obj-c tip
Categorie: Obj-C tips, iPhone | Geen reacties »

16 Sep 2009

Tip: Gegarandeerd verbinding

Op het Vodafone 3G netwerk krijg je vaak pas verbinding nadat je je app een keertje uit en terug aan hebt gezet. En dat is natuurlijk bijzonder vervelend.

Met een Auto Retry los je dit probleem doeltreffend op:

NSURLConnection Auto Retry
  1. - (void)verversGegevens
  2. {
  3. self.navigationItem.rightBarButtonItem = _reloadButtonItemWithActivity;
  4. [self.view addSubview:_propellortje];
  5. [_propellortje startAnimating];
  6. [self.tableView setAlpha:.5];
  7.  
  8. _retryCount = 0;
  9. [_connection cancel];
  10. self.request = [NSURLRequest requestWithURL:[NSURL URLWithString:_remotePath] cachePolicy:0 timeoutInterval:5];
  11. self.connection = [[NSURLConnection alloc] initWithRequest:_request delegate:self];
  12. }
  13.  
  14. #pragma mark --- NSURLConnection delegate methods ---
  15.  
  16. - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
  17. {
  18. if (_retryCount++ < 2)
  19. {
  20. [_connection cancel];
  21. self.request = [NSURLRequest requestWithURL:[NSURL URLWithString:_remotePath] cachePolicy:0 timeoutInterval:15];
  22. self.connection = [[NSURLConnection alloc] initWithRequest:_request delegate:self];
  23. NSLog(@"Connection error -> RETRY");
  24. }
  25. else
  26. {
  27. self.navigationItem.rightBarButtonItem = _reloadButtonItem;
  28. [_propellortje stopAnimating];
  29. [_propellortje removeFromSuperview];
  30. NSLog(@"Connection error %@", error);
  31.  
  32. //TODO: foutmelding naar gebruiker
  33. }
  34. }

Carl Mangold, 12:23 16 september, 2009

Labels: iPhone, obj-c, tip
Categorie: Obj-C tips, iPhone | Geen reacties »

  • RSS

    • Alle berichten
    • Alle reacties
  • Archieven

  • Kalender

    • juli 2010
      M D W D V Z Z
      « Jan    
       1234
      567891011
      12131415161718
      19202122232425
      262728293031  
  • CategoriĆ«n

    • Bright.app (4)
    • Commentaar (43)
    • iPhone (22)
    • Nieuws (2)
    • Obj-C tips (4)