SlideShare a Scribd company logo
1 of 108
mobile east
                                                       june 2012




advanced iOS
getting your knees wet, rather then your ankles




   PETE GOODLIFFE pete@goodliffe.net @petegoodliffe
@petegoodliffe
pete@goodliffe.net
goodliffe.blogspot.com
www.goodliffe.net




      PE TE G OODL
      PROGRAMME
                   IFFE
                R / AUTHOR / COLUMNIST / TEACHER ★ CON SCIENTIOUS CODER
me
you
this
iOS is a great platform to work on, and many developers have spend some time looking at
the platform. This talk is aimed at programmers with prior iOS experience who want to get
into iOS in more depth.

This presentation will take you from a basic level of understanding of iOS to look at
advanced topics that will make you apps more polished, better designed and, ideally, more
successful.

Abstract concepts are no use, so in this talk we'll take some existing successful commercial


                                      this
iOS applications as a case study, and see how a selection of iOS technologies and
techniques combine within it.

On the way, we'll see:
  ‣How to use Objective-C language facilities to their best advantage
  ‣How to exploit key iOS technologies to save you time and effort
  ‣iOS development idioms that will improve the quality of your code
  ‣Creating "universal" iPhone/iPad/retina applications without going mad
  ‣Successful deployment and testing strategies
iOS is a great platform to work on, and many developers have spend some time looking at
the platform. This talk is aimed at programmers with prior iOS experience who want to get
into iOS in more depth.

This presentation will take you from a basic level of understanding of iOS to look at
advanced topics that will make you apps more polished, better designed and, ideally, more
successful.

Abstract concepts are no use, so in this talk we'll take some existing successful commercial


                                      this
iOS applications as a case study, and see how a selection of iOS technologies and
techniques combine within it.

On the way, we'll see:
  ‣How to use Objective-C language facilities to their best advantage
  ‣How to exploit key iOS technologies to save you time and effort
  ‣iOS development idioms that will improve the quality of your code
  ‣Creating "universal" iPhone/iPad/retina applications without going mad
  ‣Successful deployment and testing strategies
the plan
but first...
http://www.dilbert.com/strips/comic/2012-04-02/
advanced
 what does that mean?
iPhone   objective C

101        cocoa
iPhone       objective C

101            cocoa




         ?
                           iPhone

                           201
topic #1
   user interface kung foo



 topic #2
”advanced” coding techniques



 topic #3
      getting animated



 topic #4
     audio shenanigans



 topic #5
         ninja tools
topic #1
user interface kung foo
advice case study code
user interface advice

    don’t be clever
     don’t be cute
     be idiomatic
standard iOS conventions
the “extra” conventions
cool stuff
cool stuff
pull to refresh
https://github.com/enormego/EGOTableViewPullRefresh
          https://github.com/leah/PullToRefresh
     https://github.com/shiki/STableViewController
cool stuff
(swipey) sidebar
https://github.com/Inferis/ViewDeck
http://cocoacontrols.com/platforms/ios/controls/pprevealsideviewcontroller

   http://cocoacontrols.com/platforms/ios/controls/hsimagesidebarview
ui joy is in the details
subtle shadow
No Carrier         00:49          Not Charging


UIBarButtonItem                Mahjong Score Book                    UINavigationBar



                                                                    UIScrollView




     UIView
      (parent)

                                                                   Custom UIView
No Carrier         00:49          Not Charging


                        Mahjong Score Book
Gradient
No C
     arrie
           r
               19:2
                   4

                       100%




                              ✘
No C
     arrie
           r
               19:2
                   4

                       100%




                              ✘
No C
                    arrie
                          r
                              19:2
                                  4

                                      100%



pass touches
  through




                                             ✔
No C
     arrie
           r
               19:2
                   4

                       100%
No C
     arrie
           r
               19:2
                   4

                       100%
@interface FadeView : UIView
@end
@interface FadeView : UIView
@end


@implementation FadeView

- (void) setUp
{
    self.backgroundColor = [UIColor clearColor];
    CAGradientLayer *gradientLayer = [[CAGradientLayer alloc] init];
    gradientLayer.colors = [NSArray arrayWithObjects:
                            (id)[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5].CGColor,
                            (id)[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0].CGColor,
                            nil];
    gradientLayer.startPoint = CGPointMake(0,0);
    gradientLayer.endPoint   = CGPointMake(0,1);
    gradientLayer.frame = CGRectMake(0,0,self.bounds.size.width, self.bounds.size.height);

       [self.layer insertSublayer:gradientLayer atIndex:0];
}

- (id) initWithCoder:(NSCoder *)aDecoder
{
    if ((self = [super initWithCoder:aDecoder]))
    {
        [self setUp];
    }
    return self;
}

- (id) initWithFrame:(CGRect)frame { /* ... */ }

@end
theming toolbars
toolbar background




         button background

   normal                    pressed




                           highlighted &
highlighted                pressed
- (void)viewDidLoad
{
    gridView.dataSource = self;
    gridView.delegate = self;
    [gridView reloadData];

    self.navigationItem.title = AppName;
    self.navigationItem.rightBarButtonItem = self.editButtonItem;
    navigationBar.items = [NSArray arrayWithObject:self.navigationItem];
    [self setEditing:NO animated:NO];

    if ([[UINavigationBar class] respondsToSelector:@selector(appearance)])
    {
        UIEdgeInsets insets = {6, 6, 6, 6};
        UIImage *image = [[UIImage imageNamed:@"ToolbarBlack"] resizableImageWithCapInsets:insets];
        [self.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
        [self styleButton:self.navigationItem.leftBarButtonItem];
        [self styleButton:self.navigationItem.rightBarButtonItem];
    }

    [super viewDidLoad];
}
- (void) setEditButtonAppearance
{
    if ([[UINavigationBar class] respondsToSelector:@selector(appearance)])
    {
        UIEdgeInsets insets = {10, 10, 10, 10};
        UIImage *navButton         = !self.editing
                                   ? [[UIImage imageNamed:@"ToolbarBlackButton"]         resizableImageWithCapInsets:insets]
                                   : [[UIImage imageNamed:@"ToolbarBlackButtonSelected"] resizableImageWithCapInsets:insets];
        UIImage *navButtonPressed = !self.editing
                                   ? [[UIImage imageNamed:@"ToolbarBlackButtonPressed"]          resizableImageWithCapInsets:insets]
                                   : [[UIImage imageNamed:@"ToolbarBlackButtonSelectedPressed"] resizableImageWithCapInsets:insets];

        [self.editButtonItem setBackgroundImage:navButton          forState:UIControlStateNormal      barMetrics:UIBarMetricsDefault];
        [self.editButtonItem setBackgroundImage:navButtonPressed   forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
    }

}
topic #2
”advanced” coding techniques
♪
three
PROBLEMS
AVAudioPlayer



✔  Play theme tune
✘ Fade in/out
categories
associative references
        blocks
PROBLEM#1


       a nice API
categories
(because one interface is never enough)
AVAudioPlayer *player = … ;
[player play];
[player stop];
AVAudioPlayer *player = … ;
[player play];
[player stop];

[player playWithFadeDuration:1.0];
[player stopWithFadeDuration:1.0];
@interface AVAudioPlayer
{
    …
}

- (id) initWithContentsOfURL:(NSURL*)url;

- (void) play;
- (void) stop;



@end
@interface AVAudioPlayer
{
    …
}

- (id) initWithContentsOfURL:(NSURL*)url;

-   (void)   play;
-   (void)   stop;
-   (void)   playWithFadeDuration:(float)secs;
-   (void)   stopWithFadeDuration:(float)secs;

@end
@interface AVAudioPlayer (Fades)

- (void) playWithFadeDuration:(float)secs;
- (void) stopWithFadeDuration:(float)secs;

@end
@implementation AVAudioPlayer (Fades)

- (void) playWithFadeDuration:(float)secs
{
    // magic happens here
}

- (void) stopWithFadeDuration:(float)secs
{
    // clever stuff in here
}

@end
AVAudioPlayer *player = … ;
[player play];
[player stop];

[player playWithFadeDuration:1.0];
[player stopWithFadeDuration:1.0];




                                     ✔
PROBLEM#2

    we need some new
    instance variables
associative references
    (a posh name for cheating)
static const char volumeLevelKey = ‘Q’;
NSNumber *number = [NSNumber numberWithFloat:1.0];

objc_setAssociatedObject(self,
    &volumeLevelKey,
    number,
    OBJ_ASSOCIATION_RETAIN_NONATOMIC);
NSNumber *number =
    (NSNumber*)objc_getAssociatedObject(self, &volumeLevelKey);
@interface AVAudioPlayer (Fades)

- (void) playWithFadeDuration:(float)secs;
- (void) stopWithFadeDuration:(float)secs;

@property float fadeVolume;

@end
- (void) fadeVolume
{
    // gibberish in here
}

- (void) setFadeVolume
{
    // cobblers in here
}




                                   ✔
float fadeVolume = player.fadeVolume;
PROBLEM#3

  we need to use another
  fancy language feature
blocks
(because C++ isn’t the only cool language)
PROBLEM#3

 when a fade has completed,
      do “something”
typedef void (^FadeCompleteBlock)();
typedef void (^FadeCompleteBlock)();




- (void) fadeToVolume:(float)volume
         withDuration:(float)secs
              andThen:(FadeCompleteBlock)action
typedef void (^FadeCompleteBlock)();

- (void) fadeToVolume:(float)volume
         withDuration:(float)secs
              andThen:(FadeCompleteBlock)action



[player fadeToVolume:0.0
        withDuration:1.0
             andThen:^{
                 [player stop];
                 player.volume = 1.0;
             }];
http://goodliffe.blogspot.co.uk/2011/04/ios-fading-avaudioplayer.html
   https://gitorious.org/audioplayerwithfade/audioplayerwithfade
topic #3
 getting animated
video>>>
- (void) documentsViewControllerSelected:(NSString*)file fromRect:(CGRect)from;
{
    lastDocumentRect = from;

    scoresViewController.filename = file;
    [scoresViewController animateAppearingFrom:from afterDelay:0.1];
    [window setRootViewController:scoresViewController animated:YES];
}
- (void) animateAppearingFrom:(CGRect)rect afterDelay:(NSTimeInterval)delay
{
    (void)self.view;

    UIImage     *image     = [mainView drawIntoImage];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

    [mainView.superview addSubview:imageView];
    imageView.frame = rect;
    mainView.hidden = YES;

    [UIView animateWithDuration:1.0
                           delay:delay
                         options:UIViewAnimationOptionAllowUserInteraction
                     animations:^{
                          imageView.frame = mainView.frame;
                     }
                     completion:^(BOOL finished){
                          mainView.hidden = NO;
                          [imageView removeFromSuperview];
                     }];
}
@interface UIView (PGLib)
- (UIImage*) drawIntoImage;
@end




- (UIImage*) drawIntoImage
{
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque,
                                           [[UIScreen mainScreen] scale]);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}
- (void) animateAppearingFrom:(CGRect)rect afterDelay:(NSTimeInterval)delay
{
    (void)self.view;

    UIImage     *image     = [mainView drawIntoImage];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

    [mainView.superview addSubview:imageView];
    imageView.frame = rect;
    mainView.hidden = YES;

    [UIView animateWithDuration:1.0
                           delay:delay
                         options:UIViewAnimationOptionAllowUserInteraction
                     animations:^{
                          imageView.frame = mainView.frame;
                     }
                     completion:^(BOOL finished){
                          mainView.hidden = NO;
                          [imageView removeFromSuperview];
                     }];
}
@interface TitlePageView : UIView
{
    CAShapeLayer *shapeLayer1;
    CAShapeLayer *shapeLayer2;
    CAShapeLayer *shapeLayer3;
    CALayer      *imageLayer;
}

@property (nonatomic, retain) IBOutlet UIButton *playButton;

-   (void)   startAnimation;
-   (void)   checkAnimationsRunning;
-   (void)   stopAnimation;
-   (void)   setBackgroundImage:(UIImage*)backgroundImage;

@end
-(void) startAnimation
{
	 CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];

	   animation.duration          = 5.0;
	   animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
	   animation.repeatCount       = 10000;
	   animation.autoreverses      = YES;
	   animation.fromValue         = [NSNumber numberWithDouble:0];
	   animation.toValue           = [NSNumber numberWithDouble:M_PI];
	   [shapeLayer1 addAnimation:animation forKey:@"animatePath"];

	   animation.duration          = 8.0;
	   [shapeLayer2 addAnimation:animation forKey:@"animatePath"];

	   animation.duration          = 13.0;
	   [shapeLayer3 addAnimation:animation forKey:@"animatePath"];
}

-(void) stopAnimation
{
    [shapeLayer1 removeAllAnimations];
    [shapeLayer2 removeAllAnimations];
    [shapeLayer3 removeAllAnimations];
}
topic #4
 audio shenanigans
you have a phone
 it makes a noise
   how do you do that?
CoreAudio

                                      Audio




            } {
                                     Services


                                     OpenAL        Headphones



                                   AVAudioPlayer    Speaker
Your code                 Audio
                         Session
                                      Audio           USB
                                      Queue

                                      Audio
                                       Unit         Bluetooth



            Audio File
             Services
Audio Session                                      Services




                                                              }                              {
                                                                             OpenAL              Phones

                                                                             AVAudioPlayer
                                                                                                 Speaker
                                                       Code       Session

                                                                              Queue               USB

                                                                                Unit               BT




                                              Phone Call



         Describe type
 App                         Doing my
         of audio use &                     INTERRUPTION!                   Resume
starts                      audio thing
          start session




                               Other apps
Audio Services                                                      Services




                                                                                         }                             {
                                                                                                       OpenAL              Phones

                                                                                                       AVAudioPlayer
                                                                                                                           Speaker
                                                                                  Code       Session

                                                                                                        Queue               USB

                                                                                                          Unit               BT
@interface Sounds : NSObject
{
     SystemSoundID lock;
}
- (void) lock;
@end



                               @implementation Sounds

                               - (id)init
                               {
                                   if ((self = [super init]))
                                   {
                                       NSBundle *bundle = [NSBundle mainBundle];
                                       NSURL    *lockUrl = [bundle URLForResource:@"Noise" withExtension:@"wav"];
                                       AudioServicesCreateSystemSoundID((__bridge CFURLRef)lockUrl, &lock);
                                   }

                                      return self;
                               }

                               - (void) lock
                               {
                                   AudioServicesPlayAlertSound(lock);
                               }

                               @end
OpenAL                                             Services




                                                               }                             {
                                                                             OpenAL              Phones

                                                                             AVAudioPlayer
                                                                                                 Speaker
                                                        Code       Session

                                                                              Queue               USB

                                                                                Unit               BT




  OpenAL is a cross-platform 3D audio API appropriate for use with
  gaming applications and many other types of audio applications.

   The library models a collection of audio sources moving in a 3D
 space that are heard by a single listener somewhere in that space.
The basic OpenAL objects are a Listener, a Source, and a Buffer. There
  can be a large number of Buffers, which contain audio data. Each
  buffer can be attached to one or more Sources, which represent
  points in 3D space which are emitting audio. There is always one
  Listener object (per audio context), which represents the position
      where the sources are heard -- rendering is done from the
                      perspective of the Listener.
AVAudioPlayer                                  Services




                                        }                             {
                                                      OpenAL              Phones

                                                      AVAudioPlayer
                                                                          Speaker
                                 Code       Session

                                                       Queue               USB

                                                         Unit               BT




“Apple recommends that you use
this class for audio playback unless




                                ”
   you are playing audio captured
 from a network stream or require
        very low I/O latency.
AVAudioPlayer                              Services




                             }                             {
                                           OpenAL              Phones

                                           AVAudioPlayer
                                                               Speaker
                      Code       Session

                                            Queue               USB

                                              Unit               BT




play single sound
    (memory or file)

      seek
  control level
   read level
Services




                                       }                             {
                                                     OpenAL              Phones

                                                     AVAudioPlayer
                                                                         Speaker
                                Code       Session

                                                      Queue               USB

                                                        Unit               BT




 Audio                     Audio
 Queue                      Unit
low latency            lowest latency
                           plug-in
                         architecture
dealing with plain old PCM audio data
topic #5
  ninja tools
#pragma mark
     . . .
             }
                 afterDelay:0.5];
    }
    return imported >= 0;
}

//==============================================================================
#pragma mark - IBActions

- (IBAction)add:(id)sender
{
    [self hideTipView];
    unsigned index = [documents addNewGame];
    [gridView
    . . .




     . . .
     [popup presentFromRect:popupRect inView:gridView.superview
                                    withText:view.name
                                  withObject:[NSNumber numberWithUnsignedInt:[gridView indexForCell:cell]]];
}

#pragma mark UIActionSheetDelegate

- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    sheet = 0;

     if (buttonIndex != 0) return;
    . . .
TestFlight
(don’t reinvent)
http://cocoacontrols.com/
http://www.stackoverflow.com/
    http://www.github.com/
QA
                  ★★★




                    &
                  ★★★


Pete Goodliffe @petegoodliffe pete@goodliffe.net
@petegoodliffe
pete@goodliffe.net
goodliffe.blogspot.com
www.goodliffe.net
BUMPH DULL, but important                            ★

THIS DOCUMENT WAS CREATED BY PETE GOODLIFFE
    IT IS COPYRIGHT // © 2012 PETE GOODLIFFE
>> ALL RIGHTS RESERVED
>> ALL THOUGHTS ARE OWNED
>> PHOTOS AND IMAGES ARE MOSTLY
    SOURCED FROM THE WEB
THANK YOU FOR READING // I HOPE IT WAS USEFUL
                                      Version 1.0 2012-08-14

More Related Content

Viewers also liked

iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework
iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework
iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework Eakapong Kattiya
 
Introduction to objective c
Introduction to objective cIntroduction to objective c
Introduction to objective cSunny Shaikh
 
Smart Lock for Password @ Game DevFest Bangkok 2015
Smart Lock for Password @ Game DevFest Bangkok 2015Smart Lock for Password @ Game DevFest Bangkok 2015
Smart Lock for Password @ Game DevFest Bangkok 2015Somkiat Khitwongwattana
 
Objective-C for iOS Application Development
Objective-C for iOS Application DevelopmentObjective-C for iOS Application Development
Objective-C for iOS Application DevelopmentDhaval Kaneria
 
Introduction to xcode
Introduction to xcodeIntroduction to xcode
Introduction to xcodeSunny Shaikh
 
Deep dive into android restoration - DroidCon Paris 2014
Deep dive into android restoration - DroidCon Paris 2014Deep dive into android restoration - DroidCon Paris 2014
Deep dive into android restoration - DroidCon Paris 2014Paris Android User Group
 
Web Services with Objective-C
Web Services with Objective-CWeb Services with Objective-C
Web Services with Objective-CJuio Barros
 
iOS Development - A Beginner Guide
iOS Development - A Beginner GuideiOS Development - A Beginner Guide
iOS Development - A Beginner GuideAndri Yadi
 
Introduction to Objective - C
Introduction to Objective - CIntroduction to Objective - C
Introduction to Objective - CJussi Pohjolainen
 
Apple iOS Introduction
Apple iOS IntroductionApple iOS Introduction
Apple iOS IntroductionPratik Vyas
 
Prenetics InsurTech Award Presentation
Prenetics InsurTech Award PresentationPrenetics InsurTech Award Presentation
Prenetics InsurTech Award PresentationThe Digital Insurer
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CDataArt
 

Viewers also liked (19)

iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework
iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework
iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework
 
Introduction to objective c
Introduction to objective cIntroduction to objective c
Introduction to objective c
 
iOS Basic
iOS BasiciOS Basic
iOS Basic
 
Smart Lock for Password @ Game DevFest Bangkok 2015
Smart Lock for Password @ Game DevFest Bangkok 2015Smart Lock for Password @ Game DevFest Bangkok 2015
Smart Lock for Password @ Game DevFest Bangkok 2015
 
Objective-C for iOS Application Development
Objective-C for iOS Application DevelopmentObjective-C for iOS Application Development
Objective-C for iOS Application Development
 
Introduction to xcode
Introduction to xcodeIntroduction to xcode
Introduction to xcode
 
iOS
iOSiOS
iOS
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
 
Deep dive into android restoration - DroidCon Paris 2014
Deep dive into android restoration - DroidCon Paris 2014Deep dive into android restoration - DroidCon Paris 2014
Deep dive into android restoration - DroidCon Paris 2014
 
Web Services with Objective-C
Web Services with Objective-CWeb Services with Objective-C
Web Services with Objective-C
 
Advance Android Layout Walkthrough
Advance Android Layout WalkthroughAdvance Android Layout Walkthrough
Advance Android Layout Walkthrough
 
iOS Development - A Beginner Guide
iOS Development - A Beginner GuideiOS Development - A Beginner Guide
iOS Development - A Beginner Guide
 
Introduction to Objective - C
Introduction to Objective - CIntroduction to Objective - C
Introduction to Objective - C
 
Apple iOS Introduction
Apple iOS IntroductionApple iOS Introduction
Apple iOS Introduction
 
Ios operating system
Ios operating systemIos operating system
Ios operating system
 
200810 - iPhone Tutorial
200810 - iPhone Tutorial200810 - iPhone Tutorial
200810 - iPhone Tutorial
 
Prenetics InsurTech Award Presentation
Prenetics InsurTech Award PresentationPrenetics InsurTech Award Presentation
Prenetics InsurTech Award Presentation
 
Apple iOS
Apple iOSApple iOS
Apple iOS
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-C
 

Similar to Advanced iOS

Style vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOSStyle vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOSKeith Norman
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentanistar sung
 
Getting Started With Material Design
Getting Started With Material DesignGetting Started With Material Design
Getting Started With Material DesignYasin Yildirim
 
IBDesignable - CocoaConf Seattle 2014
IBDesignable - CocoaConf Seattle 2014IBDesignable - CocoaConf Seattle 2014
IBDesignable - CocoaConf Seattle 2014Martin Nash
 
Cordova: Making Native Mobile Apps With Your Web Skills
Cordova: Making Native Mobile Apps With Your Web SkillsCordova: Making Native Mobile Apps With Your Web Skills
Cordova: Making Native Mobile Apps With Your Web SkillsClay Ewing
 
用 IBDesignable 作 UI
用 IBDesignable 作 UI用 IBDesignable 作 UI
用 IBDesignable 作 UITsungyu Yu
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder BehindJohn Wilker
 
RubyMotion
RubyMotionRubyMotion
RubyMotionMark
 
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil TayarVisual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil TayarApplitools
 
MNT2014: Mobile Hibrido com Phonegap
MNT2014: Mobile Hibrido com PhonegapMNT2014: Mobile Hibrido com Phonegap
MNT2014: Mobile Hibrido com PhonegapLoiane Groner
 
Creating a flawless user experience, end to-end, functional to visual - Slide...
Creating a flawless user experience, end to-end, functional to visual - Slide...Creating a flawless user experience, end to-end, functional to visual - Slide...
Creating a flawless user experience, end to-end, functional to visual - Slide...Applitools
 
Building a Native Camera Access Library - Part I - Transcript.pdf
Building a Native Camera Access Library - Part I - Transcript.pdfBuilding a Native Camera Access Library - Part I - Transcript.pdf
Building a Native Camera Access Library - Part I - Transcript.pdfShaiAlmog1
 
Fake it 'til you make it
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make itJonathan Snook
 
Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...
Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...
Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ....NET Conf UY
 
CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads France
 
iPhone Camp Birmingham (Bham) - Intro To iPhone Development
iPhone Camp Birmingham (Bham) - Intro To iPhone DevelopmentiPhone Camp Birmingham (Bham) - Intro To iPhone Development
iPhone Camp Birmingham (Bham) - Intro To iPhone Developmentandriajensen
 
Developing AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalDeveloping AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalChris Griffith
 
iOSインタラクションデザイン
iOSインタラクションデザインiOSインタラクションデザイン
iOSインタラクションデザインhIDDENxv
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)Bramus Van Damme
 

Similar to Advanced iOS (20)

Style vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOSStyle vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOS
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
Getting Started With Material Design
Getting Started With Material DesignGetting Started With Material Design
Getting Started With Material Design
 
IBDesignable - CocoaConf Seattle 2014
IBDesignable - CocoaConf Seattle 2014IBDesignable - CocoaConf Seattle 2014
IBDesignable - CocoaConf Seattle 2014
 
Cordova: Making Native Mobile Apps With Your Web Skills
Cordova: Making Native Mobile Apps With Your Web SkillsCordova: Making Native Mobile Apps With Your Web Skills
Cordova: Making Native Mobile Apps With Your Web Skills
 
用 IBDesignable 作 UI
用 IBDesignable 作 UI用 IBDesignable 作 UI
用 IBDesignable 作 UI
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder Behind
 
RubyMotion
RubyMotionRubyMotion
RubyMotion
 
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil TayarVisual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
 
MNT2014: Mobile Hibrido com Phonegap
MNT2014: Mobile Hibrido com PhonegapMNT2014: Mobile Hibrido com Phonegap
MNT2014: Mobile Hibrido com Phonegap
 
Pc54
Pc54Pc54
Pc54
 
Creating a flawless user experience, end to-end, functional to visual - Slide...
Creating a flawless user experience, end to-end, functional to visual - Slide...Creating a flawless user experience, end to-end, functional to visual - Slide...
Creating a flawless user experience, end to-end, functional to visual - Slide...
 
Building a Native Camera Access Library - Part I - Transcript.pdf
Building a Native Camera Access Library - Part I - Transcript.pdfBuilding a Native Camera Access Library - Part I - Transcript.pdf
Building a Native Camera Access Library - Part I - Transcript.pdf
 
Fake it 'til you make it
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make it
 
Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...
Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...
Tips & tricks for sharing C# code on iOS, Android and Windows Phone by Jaime ...
 
CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIView
 
iPhone Camp Birmingham (Bham) - Intro To iPhone Development
iPhone Camp Birmingham (Bham) - Intro To iPhone DevelopmentiPhone Camp Birmingham (Bham) - Intro To iPhone Development
iPhone Camp Birmingham (Bham) - Intro To iPhone Development
 
Developing AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalDeveloping AIR for Android with Flash Professional
Developing AIR for Android with Flash Professional
 
iOSインタラクションデザイン
iOSインタラクションデザインiOSインタラクションデザイン
iOSインタラクションデザイン
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)
 

More from Pete Goodliffe

Becoming a Better Programmer
Becoming a Better ProgrammerBecoming a Better Programmer
Becoming a Better ProgrammerPete Goodliffe
 
Running Effective Worship Rehearsals
Running Effective Worship RehearsalsRunning Effective Worship Rehearsals
Running Effective Worship RehearsalsPete Goodliffe
 
Becoming a Better Programmer (2013)
Becoming a Better Programmer (2013)Becoming a Better Programmer (2013)
Becoming a Better Programmer (2013)Pete Goodliffe
 
Version Control Done Right
Version Control Done RightVersion Control Done Right
Version Control Done RightPete Goodliffe
 
C++: The Cathedral and the Bizarre
C++: The Cathedral and the BizarreC++: The Cathedral and the Bizarre
C++: The Cathedral and the BizarrePete Goodliffe
 
iOS Development (BCS Newcastle)
iOS Development (BCS Newcastle)iOS Development (BCS Newcastle)
iOS Development (BCS Newcastle)Pete Goodliffe
 
Three Objectionable Things
Three Objectionable ThingsThree Objectionable Things
Three Objectionable ThingsPete Goodliffe
 
Coping with Complexity
Coping with ComplexityCoping with Complexity
Coping with ComplexityPete Goodliffe
 
iOS Development (BCS Edinburgh 2011-03-09)
iOS Development (BCS Edinburgh 2011-03-09)iOS Development (BCS Edinburgh 2011-03-09)
iOS Development (BCS Edinburgh 2011-03-09)Pete Goodliffe
 
Stood at the bottom of a mountain looking up
Stood at the bottom of a mountain looking upStood at the bottom of a mountain looking up
Stood at the bottom of a mountain looking upPete Goodliffe
 
iPhone development: A brief introduction
iPhone development: A brief introductioniPhone development: A brief introduction
iPhone development: A brief introductionPete Goodliffe
 
Legacy Code: Learning To Live With It
Legacy Code: Learning To Live With ItLegacy Code: Learning To Live With It
Legacy Code: Learning To Live With ItPete Goodliffe
 

More from Pete Goodliffe (16)

Becoming a Better Programmer
Becoming a Better ProgrammerBecoming a Better Programmer
Becoming a Better Programmer
 
Words in Code
Words in CodeWords in Code
Words in Code
 
Running Effective Worship Rehearsals
Running Effective Worship RehearsalsRunning Effective Worship Rehearsals
Running Effective Worship Rehearsals
 
Becoming a Better Programmer (2013)
Becoming a Better Programmer (2013)Becoming a Better Programmer (2013)
Becoming a Better Programmer (2013)
 
Design Sins
Design SinsDesign Sins
Design Sins
 
Version Control Done Right
Version Control Done RightVersion Control Done Right
Version Control Done Right
 
Getting Into Git
Getting Into GitGetting Into Git
Getting Into Git
 
C++: The Cathedral and the Bizarre
C++: The Cathedral and the BizarreC++: The Cathedral and the Bizarre
C++: The Cathedral and the Bizarre
 
iOS Development (BCS Newcastle)
iOS Development (BCS Newcastle)iOS Development (BCS Newcastle)
iOS Development (BCS Newcastle)
 
Three Objectionable Things
Three Objectionable ThingsThree Objectionable Things
Three Objectionable Things
 
Coping with Complexity
Coping with ComplexityCoping with Complexity
Coping with Complexity
 
Manyfestos
ManyfestosManyfestos
Manyfestos
 
iOS Development (BCS Edinburgh 2011-03-09)
iOS Development (BCS Edinburgh 2011-03-09)iOS Development (BCS Edinburgh 2011-03-09)
iOS Development (BCS Edinburgh 2011-03-09)
 
Stood at the bottom of a mountain looking up
Stood at the bottom of a mountain looking upStood at the bottom of a mountain looking up
Stood at the bottom of a mountain looking up
 
iPhone development: A brief introduction
iPhone development: A brief introductioniPhone development: A brief introduction
iPhone development: A brief introduction
 
Legacy Code: Learning To Live With It
Legacy Code: Learning To Live With ItLegacy Code: Learning To Live With It
Legacy Code: Learning To Live With It
 

Recently uploaded

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

Advanced iOS

  • 1. mobile east june 2012 advanced iOS getting your knees wet, rather then your ankles PETE GOODLIFFE pete@goodliffe.net @petegoodliffe
  • 2. @petegoodliffe pete@goodliffe.net goodliffe.blogspot.com www.goodliffe.net PE TE G OODL PROGRAMME IFFE R / AUTHOR / COLUMNIST / TEACHER ★ CON SCIENTIOUS CODER
  • 3.
  • 4. me
  • 5. you
  • 7. iOS is a great platform to work on, and many developers have spend some time looking at the platform. This talk is aimed at programmers with prior iOS experience who want to get into iOS in more depth. This presentation will take you from a basic level of understanding of iOS to look at advanced topics that will make you apps more polished, better designed and, ideally, more successful. Abstract concepts are no use, so in this talk we'll take some existing successful commercial this iOS applications as a case study, and see how a selection of iOS technologies and techniques combine within it. On the way, we'll see: ‣How to use Objective-C language facilities to their best advantage ‣How to exploit key iOS technologies to save you time and effort ‣iOS development idioms that will improve the quality of your code ‣Creating "universal" iPhone/iPad/retina applications without going mad ‣Successful deployment and testing strategies
  • 8. iOS is a great platform to work on, and many developers have spend some time looking at the platform. This talk is aimed at programmers with prior iOS experience who want to get into iOS in more depth. This presentation will take you from a basic level of understanding of iOS to look at advanced topics that will make you apps more polished, better designed and, ideally, more successful. Abstract concepts are no use, so in this talk we'll take some existing successful commercial this iOS applications as a case study, and see how a selection of iOS technologies and techniques combine within it. On the way, we'll see: ‣How to use Objective-C language facilities to their best advantage ‣How to exploit key iOS technologies to save you time and effort ‣iOS development idioms that will improve the quality of your code ‣Creating "universal" iPhone/iPad/retina applications without going mad ‣Successful deployment and testing strategies
  • 12.
  • 13. advanced what does that mean?
  • 14. iPhone objective C 101 cocoa
  • 15. iPhone objective C 101 cocoa ? iPhone 201
  • 16. topic #1 user interface kung foo topic #2 ”advanced” coding techniques topic #3 getting animated topic #4 audio shenanigans topic #5 ninja tools
  • 19. user interface advice don’t be clever don’t be cute be idiomatic
  • 24.
  • 26. https://github.com/enormego/EGOTableViewPullRefresh https://github.com/leah/PullToRefresh https://github.com/shiki/STableViewController
  • 28.
  • 29.
  • 30.
  • 32.
  • 34. ui joy is in the details
  • 35.
  • 36.
  • 37.
  • 38.
  • 40. No Carrier 00:49 Not Charging UIBarButtonItem Mahjong Score Book UINavigationBar UIScrollView UIView (parent) Custom UIView
  • 41. No Carrier 00:49 Not Charging Mahjong Score Book Gradient
  • 42. No C arrie r 19:2 4 100% ✘
  • 43. No C arrie r 19:2 4 100% ✘
  • 44. No C arrie r 19:2 4 100% pass touches through ✔
  • 45. No C arrie r 19:2 4 100%
  • 46. No C arrie r 19:2 4 100%
  • 47. @interface FadeView : UIView @end
  • 48. @interface FadeView : UIView @end @implementation FadeView - (void) setUp { self.backgroundColor = [UIColor clearColor]; CAGradientLayer *gradientLayer = [[CAGradientLayer alloc] init]; gradientLayer.colors = [NSArray arrayWithObjects: (id)[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5].CGColor, (id)[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0].CGColor, nil]; gradientLayer.startPoint = CGPointMake(0,0); gradientLayer.endPoint = CGPointMake(0,1); gradientLayer.frame = CGRectMake(0,0,self.bounds.size.width, self.bounds.size.height); [self.layer insertSublayer:gradientLayer atIndex:0]; } - (id) initWithCoder:(NSCoder *)aDecoder { if ((self = [super initWithCoder:aDecoder])) { [self setUp]; } return self; } - (id) initWithFrame:(CGRect)frame { /* ... */ } @end
  • 50. toolbar background button background normal pressed highlighted & highlighted pressed
  • 51. - (void)viewDidLoad { gridView.dataSource = self; gridView.delegate = self; [gridView reloadData]; self.navigationItem.title = AppName; self.navigationItem.rightBarButtonItem = self.editButtonItem; navigationBar.items = [NSArray arrayWithObject:self.navigationItem]; [self setEditing:NO animated:NO]; if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) { UIEdgeInsets insets = {6, 6, 6, 6}; UIImage *image = [[UIImage imageNamed:@"ToolbarBlack"] resizableImageWithCapInsets:insets]; [self.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; [self styleButton:self.navigationItem.leftBarButtonItem]; [self styleButton:self.navigationItem.rightBarButtonItem]; } [super viewDidLoad]; }
  • 52. - (void) setEditButtonAppearance { if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) { UIEdgeInsets insets = {10, 10, 10, 10}; UIImage *navButton = !self.editing ? [[UIImage imageNamed:@"ToolbarBlackButton"] resizableImageWithCapInsets:insets] : [[UIImage imageNamed:@"ToolbarBlackButtonSelected"] resizableImageWithCapInsets:insets]; UIImage *navButtonPressed = !self.editing ? [[UIImage imageNamed:@"ToolbarBlackButtonPressed"] resizableImageWithCapInsets:insets] : [[UIImage imageNamed:@"ToolbarBlackButtonSelectedPressed"] resizableImageWithCapInsets:insets]; [self.editButtonItem setBackgroundImage:navButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [self.editButtonItem setBackgroundImage:navButtonPressed forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault]; } }
  • 54.
  • 56. AVAudioPlayer ✔ Play theme tune ✘ Fade in/out
  • 58. PROBLEM#1 a nice API
  • 60. AVAudioPlayer *player = … ; [player play]; [player stop];
  • 61. AVAudioPlayer *player = … ; [player play]; [player stop]; [player playWithFadeDuration:1.0]; [player stopWithFadeDuration:1.0];
  • 62. @interface AVAudioPlayer { … } - (id) initWithContentsOfURL:(NSURL*)url; - (void) play; - (void) stop; @end
  • 63. @interface AVAudioPlayer { … } - (id) initWithContentsOfURL:(NSURL*)url; - (void) play; - (void) stop; - (void) playWithFadeDuration:(float)secs; - (void) stopWithFadeDuration:(float)secs; @end
  • 64. @interface AVAudioPlayer (Fades) - (void) playWithFadeDuration:(float)secs; - (void) stopWithFadeDuration:(float)secs; @end
  • 65. @implementation AVAudioPlayer (Fades) - (void) playWithFadeDuration:(float)secs { // magic happens here } - (void) stopWithFadeDuration:(float)secs { // clever stuff in here } @end
  • 66. AVAudioPlayer *player = … ; [player play]; [player stop]; [player playWithFadeDuration:1.0]; [player stopWithFadeDuration:1.0]; ✔
  • 67. PROBLEM#2 we need some new instance variables
  • 68. associative references (a posh name for cheating)
  • 69. static const char volumeLevelKey = ‘Q’; NSNumber *number = [NSNumber numberWithFloat:1.0]; objc_setAssociatedObject(self, &volumeLevelKey, number, OBJ_ASSOCIATION_RETAIN_NONATOMIC);
  • 70. NSNumber *number = (NSNumber*)objc_getAssociatedObject(self, &volumeLevelKey);
  • 71. @interface AVAudioPlayer (Fades) - (void) playWithFadeDuration:(float)secs; - (void) stopWithFadeDuration:(float)secs; @property float fadeVolume; @end
  • 72. - (void) fadeVolume { // gibberish in here } - (void) setFadeVolume { // cobblers in here } ✔ float fadeVolume = player.fadeVolume;
  • 73. PROBLEM#3 we need to use another fancy language feature
  • 74. blocks (because C++ isn’t the only cool language)
  • 75. PROBLEM#3 when a fade has completed, do “something”
  • 77. typedef void (^FadeCompleteBlock)(); - (void) fadeToVolume:(float)volume withDuration:(float)secs andThen:(FadeCompleteBlock)action
  • 78. typedef void (^FadeCompleteBlock)(); - (void) fadeToVolume:(float)volume withDuration:(float)secs andThen:(FadeCompleteBlock)action [player fadeToVolume:0.0 withDuration:1.0 andThen:^{ [player stop]; player.volume = 1.0; }];
  • 79. http://goodliffe.blogspot.co.uk/2011/04/ios-fading-avaudioplayer.html https://gitorious.org/audioplayerwithfade/audioplayerwithfade
  • 80. topic #3 getting animated
  • 82.
  • 83. - (void) documentsViewControllerSelected:(NSString*)file fromRect:(CGRect)from; { lastDocumentRect = from; scoresViewController.filename = file; [scoresViewController animateAppearingFrom:from afterDelay:0.1]; [window setRootViewController:scoresViewController animated:YES]; }
  • 84. - (void) animateAppearingFrom:(CGRect)rect afterDelay:(NSTimeInterval)delay { (void)self.view; UIImage *image = [mainView drawIntoImage]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; [mainView.superview addSubview:imageView]; imageView.frame = rect; mainView.hidden = YES; [UIView animateWithDuration:1.0 delay:delay options:UIViewAnimationOptionAllowUserInteraction animations:^{ imageView.frame = mainView.frame; } completion:^(BOOL finished){ mainView.hidden = NO; [imageView removeFromSuperview]; }]; }
  • 85. @interface UIView (PGLib) - (UIImage*) drawIntoImage; @end - (UIImage*) drawIntoImage { UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, [[UIScreen mainScreen] scale]); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }
  • 86. - (void) animateAppearingFrom:(CGRect)rect afterDelay:(NSTimeInterval)delay { (void)self.view; UIImage *image = [mainView drawIntoImage]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; [mainView.superview addSubview:imageView]; imageView.frame = rect; mainView.hidden = YES; [UIView animateWithDuration:1.0 delay:delay options:UIViewAnimationOptionAllowUserInteraction animations:^{ imageView.frame = mainView.frame; } completion:^(BOOL finished){ mainView.hidden = NO; [imageView removeFromSuperview]; }]; }
  • 87.
  • 88.
  • 89. @interface TitlePageView : UIView { CAShapeLayer *shapeLayer1; CAShapeLayer *shapeLayer2; CAShapeLayer *shapeLayer3; CALayer *imageLayer; } @property (nonatomic, retain) IBOutlet UIButton *playButton; - (void) startAnimation; - (void) checkAnimationsRunning; - (void) stopAnimation; - (void) setBackgroundImage:(UIImage*)backgroundImage; @end
  • 90. -(void) startAnimation { CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.duration = 5.0; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; animation.repeatCount = 10000; animation.autoreverses = YES; animation.fromValue = [NSNumber numberWithDouble:0]; animation.toValue = [NSNumber numberWithDouble:M_PI]; [shapeLayer1 addAnimation:animation forKey:@"animatePath"]; animation.duration = 8.0; [shapeLayer2 addAnimation:animation forKey:@"animatePath"]; animation.duration = 13.0; [shapeLayer3 addAnimation:animation forKey:@"animatePath"]; } -(void) stopAnimation { [shapeLayer1 removeAllAnimations]; [shapeLayer2 removeAllAnimations]; [shapeLayer3 removeAllAnimations]; }
  • 91. topic #4 audio shenanigans
  • 92. you have a phone it makes a noise how do you do that?
  • 93. CoreAudio Audio } { Services OpenAL Headphones AVAudioPlayer Speaker Your code Audio Session Audio USB Queue Audio Unit Bluetooth Audio File Services
  • 94. Audio Session Services } { OpenAL Phones AVAudioPlayer Speaker Code Session Queue USB Unit BT Phone Call Describe type App Doing my of audio use & INTERRUPTION! Resume starts audio thing start session Other apps
  • 95. Audio Services Services } { OpenAL Phones AVAudioPlayer Speaker Code Session Queue USB Unit BT @interface Sounds : NSObject { SystemSoundID lock; } - (void) lock; @end @implementation Sounds - (id)init { if ((self = [super init])) { NSBundle *bundle = [NSBundle mainBundle]; NSURL *lockUrl = [bundle URLForResource:@"Noise" withExtension:@"wav"]; AudioServicesCreateSystemSoundID((__bridge CFURLRef)lockUrl, &lock); } return self; } - (void) lock { AudioServicesPlayAlertSound(lock); } @end
  • 96. OpenAL Services } { OpenAL Phones AVAudioPlayer Speaker Code Session Queue USB Unit BT OpenAL is a cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications. The library models a collection of audio sources moving in a 3D space that are heard by a single listener somewhere in that space. The basic OpenAL objects are a Listener, a Source, and a Buffer. There can be a large number of Buffers, which contain audio data. Each buffer can be attached to one or more Sources, which represent points in 3D space which are emitting audio. There is always one Listener object (per audio context), which represents the position where the sources are heard -- rendering is done from the perspective of the Listener.
  • 97. AVAudioPlayer Services } { OpenAL Phones AVAudioPlayer Speaker Code Session Queue USB Unit BT “Apple recommends that you use this class for audio playback unless ” you are playing audio captured from a network stream or require very low I/O latency.
  • 98. AVAudioPlayer Services } { OpenAL Phones AVAudioPlayer Speaker Code Session Queue USB Unit BT play single sound (memory or file) seek control level read level
  • 99. Services } { OpenAL Phones AVAudioPlayer Speaker Code Session Queue USB Unit BT Audio Audio Queue Unit low latency lowest latency plug-in architecture dealing with plain old PCM audio data
  • 100. topic #5 ninja tools
  • 101. #pragma mark . . . } afterDelay:0.5]; } return imported >= 0; } //============================================================================== #pragma mark - IBActions - (IBAction)add:(id)sender { [self hideTipView]; unsigned index = [documents addNewGame]; [gridView . . . . . . [popup presentFromRect:popupRect inView:gridView.superview withText:view.name withObject:[NSNumber numberWithUnsignedInt:[gridView indexForCell:cell]]]; } #pragma mark UIActionSheetDelegate - (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { sheet = 0; if (buttonIndex != 0) return; . . .
  • 103.
  • 106. QA ★★★ & ★★★ Pete Goodliffe @petegoodliffe pete@goodliffe.net
  • 108. BUMPH DULL, but important ★ THIS DOCUMENT WAS CREATED BY PETE GOODLIFFE IT IS COPYRIGHT // © 2012 PETE GOODLIFFE >> ALL RIGHTS RESERVED >> ALL THOUGHTS ARE OWNED >> PHOTOS AND IMAGES ARE MOSTLY SOURCED FROM THE WEB THANK YOU FOR READING // I HOPE IT WAS USEFUL Version 1.0 2012-08-14