SlideShare a Scribd company logo
iOS Training Session-3
iOS Application Development
        -Hussain KMR Behestee
           The Jaxara IT LTD.
              [Session-3]
Agendas


∗ Programming with Segue
∗ Dynamic design through coding
  ∗ Views and its Co-ordinates
∗ Core animations
∗ Picture pickers
∗ Sound manager
∗ Address book picker
Programming with Segue
Segue in Storyboarding
Programming with Segue
What is Segue?
Programming with Segue
Life Cycle of Segue
∗ Your app never creates segue objects directly, they are always created on
  your behalf by iOS when a segue is triggered.
∗ The destination controller is created and initialized.
∗ The segue object is created and its initWithIdentifier:source:destination:
  method is called. The identifier is the unique string you provided for the
  segue in Interface Builder, and the two other parameters represent the
  two controller objects in the transition.
∗ The source view controller’s prepareForSegue:sender: method is called.
∗ The segue object’s perform method is called. This method performs a
  transition to bring the destination view controller on-screen.
∗ The reference to the segue object is released, causing it to be
  deallocated.
Programming with Segue

Triggering a segue programmatically
- (void)orientationChanged:(NSNotification *)notification
{
   UIDeviceOrientation deviceOrientation =
            [UIDevice currentDevice].orientation;

    if (UIDeviceOrientationIsLandscape(deviceOrientation) &&
       !isShowingLandscapeView)

    {
        [self performSegueWithIdentifier:@"DisplayAlternateView" sender:self];
        isShowingLandscapeView = YES;
    }
}
Dynamic design through coding


        UIView's frame:     The CGPoint:           The CGSize :
        struct CGRect       struct CGPoint         struct CGSize
        { CGPoint origin;   { CGFloat x; CGFloat   { CGFloat width;
        CGSize size; };     y; };                  CGFloat height; };


        [button setFrame:CGRectMake(x, y, width, height)];
Dynamic design through coding
Dynamic design through coding


∗ Creating UI Object on the fly
  UIImageView* campFireView = [[UIImageView alloc]
    initWithFrame: self.view.frame];
  campFireView.image = [UIImage
    imageWithName:@"image.png"];
∗ Adding to view
  [self.view addSubview: campFireView];
Core animations


∗ View Based Animation
  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:0.8];
  //animation logic here
  [UIView commitAnimations];
∗ Set animation complete callback
  [UIView setAnimationDidStopSelector:
    @selector(onAnimationComplete:finished:context:)];
∗ onAnimationComplete – Callback
  - (void)onAnimationComplete:(NSString *)animationID finished:
      (NSNumber *)finished context:(void *)context
Core animations

∗ Image Based Animation
   ∗   create the view that will execute our animation
   UIImageView* campFireView = [[UIImageView alloc]
      initWithFrame:self.view.frame];
   ∗   load all the frames of our animation
   campFireView.animationImages = [NSArray arrayWithObjects:
        [UIImage imageNamed:@"campFire01.gif"],
        [UIImage imageNamed:@"campFire02.gif"], nil];
   campFireView.animationDuration = 1.75;
   ∗   repeat the annimation forever
   campFireView.animationRepeatCount = 0;
   ∗   start animating
   [campFireView startAnimating];
   ∗ add the animation view to the main window
   [self.view addSubview:campFireView];
Picture pickers
Initialization..

∗ Initialize the Image Picker and set delegate for interaction
  picker = [[UIImagePickerController alloc] init];
  picker.delegate = self;
∗ Checking and setting Source type
  if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
           picker.sourceType = UIImagePickerControllerSourceTypeCamera;
  } else{
           picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  }

∗ Call the picker to front
  [self presentViewController:picker animated:YES completion:NULL];
Picture pickers
Grabbing the image

∗ If the user cancels we just dismiss the picker and release the object
    - (void)imagePickerControllerDidCancel:(UIImagePickerController *) Picker
    {
             [[picker presentingViewController] dismissViewControllerAnimated:YES
                         completion:NULL];
    }
∗ But if the user selects an image or takes a photo with the camera
    (void)imagePickerController:(UIImagePickerController *)picker
    didFinishPickingMediaWithInfo:(NSDictionary *)info{
    {
            selectedImage.image = [info
                       objectForKey:UIImagePickerControllerOriginalImage];

            [[picker presentingViewController] dismissViewControllerAnimated:YES
                        completion:NULL];
    }
∗   For more information
Sound manager


∗ Get the main bundle for the app
  CFBundleRef mainBundle = CFBundleGetMainBundle ();
∗ Get the URL to the sound file to play
  CFURLRef soundFileURLRef;
  soundFileURLRef = CFBundleCopyResourceURL ( mainBundle,
    CFSTR ("tap"), CFSTR ("aif"), NULL);
∗ Create a system sound object representing the sound file
  SystemSoundID soundFileObject;
  AudioServicesCreateSystemSoundID (soundFileURLRef,
    &soundFileObject);
Sound manager


∗ For System Sound Play
  AudioServicesPlaySystemSound (soundFileObject);
∗ For Alert Sound Play
  AudioServicesPlayAlertSound (soundFileObject);
∗ For Vibrate Play
  AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
Address book picker


∗   Add Framework: AddressBookUI, AddressBook
∗   Add Header File: #import <AddressBookUI/AddressBookUI.h>
∗   Add Protocol : ABPeoplePickerNavigationControllerDelegate
∗   Responding to User Events
    ∗ peoplePickerNavigationController:shouldContinueAfterSelectingPerson:
    ∗ peoplePickerNavigationController:shouldContinueAfterSelectingPerson:pro
      perty:identifier:
    ∗ peoplePickerNavigationControllerDidCancel:
Address book picker
Address book picker
Address book picker
Address book picker
Question?




Thanks

More Related Content

PDF
Core Animation
PDF
libGDX: Scene2D
PDF
Webgl para JavaScripters
PDF
Implementing a Simple Game using libGDX
PDF
飛び道具ではないMetal #iOSDC
PDF
Material Design and Backwards Compatibility
PDF
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
PDF
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
Core Animation
libGDX: Scene2D
Webgl para JavaScripters
Implementing a Simple Game using libGDX
飛び道具ではないMetal #iOSDC
Material Design and Backwards Compatibility
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient

What's hot (20)

PDF
Model View Intent on Android
PDF
Box2D and libGDX
PPT
Building Robust jQuery Plugins
PDF
The Ring programming language version 1.5.1 book - Part 45 of 180
PDF
Tools for developing Android Games
PDF
A split screen-viable UI event system - Unite Copenhagen 2019
PPTX
Game Project / Working with Unity
PDF
Useful Tools for Making Video Games - Irrlicht (2008)
PDF
libGDX: User Input and Frame by Frame Animation
PDF
Unity遊戲程式設計(15) 實作Space shooter遊戲
PDF
libGDX: Tiled Maps
PDF
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
PPTX
Cross-scene references: A shock to the system - Unite Copenhagen 2019
PDF
Daniel Jalkut - dotSwift 2019
PPTX
Unity workshop
PDF
Asynchronous Programming with JavaScript
PDF
QML\Qt Quick на практике
PDF
Node meetup feb_20_12
KEY
I phone勉強会 (2011.11.23)
Model View Intent on Android
Box2D and libGDX
Building Robust jQuery Plugins
The Ring programming language version 1.5.1 book - Part 45 of 180
Tools for developing Android Games
A split screen-viable UI event system - Unite Copenhagen 2019
Game Project / Working with Unity
Useful Tools for Making Video Games - Irrlicht (2008)
libGDX: User Input and Frame by Frame Animation
Unity遊戲程式設計(15) 實作Space shooter遊戲
libGDX: Tiled Maps
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Cross-scene references: A shock to the system - Unite Copenhagen 2019
Daniel Jalkut - dotSwift 2019
Unity workshop
Asynchronous Programming with JavaScript
QML\Qt Quick на практике
Node meetup feb_20_12
I phone勉強会 (2011.11.23)
Ad

Viewers also liked (20)

DOCX
Best Apple IOS Training in Chennai | Best Iphone Training in Chennai
PPTX
iOS 8 App Extensions
PDF
iOS and Android Training Workshops 2016 by Teks Mobile Sverige
PPTX
Android session 3-behestee
PPTX
iOS app dev Training - Session1
PPTX
Android session-1-sajib
PPTX
Android session-5-sajib
PPT
ASP.NET MVC introduction
PPTX
Android session 2-behestee
PDF
Echelon MillionAir magazine
PPTX
CodeCamp general info
PPTX
iOS Session-2
PPTX
Android session 4-behestee
PPTX
iOS Developer Online Training
PPTX
Apple Watch and WatchKit - A Technical Overview
PPTX
First Steps in iOS Development
PPTX
iOS training (basic)
PPT
iPhone application development training day 1
PDF
Build Your First iOS App With Swift
PPTX
iOS training (intermediate)
Best Apple IOS Training in Chennai | Best Iphone Training in Chennai
iOS 8 App Extensions
iOS and Android Training Workshops 2016 by Teks Mobile Sverige
Android session 3-behestee
iOS app dev Training - Session1
Android session-1-sajib
Android session-5-sajib
ASP.NET MVC introduction
Android session 2-behestee
Echelon MillionAir magazine
CodeCamp general info
iOS Session-2
Android session 4-behestee
iOS Developer Online Training
Apple Watch and WatchKit - A Technical Overview
First Steps in iOS Development
iOS training (basic)
iPhone application development training day 1
Build Your First iOS App With Swift
iOS training (intermediate)
Ad

Similar to iOS Training Session-3 (20)

PPT
08 objective-c session 8
PDF
iPhone dev intro
PDF
Beginning to iPhone development
PDF
Assignment 4 Paparazzi1
PPTX
iOS Development (Part 3) - Additional GUI Components
PDF
My Favourite 10 Things about Xcode/ObjectiveC
PDF
Paparazzi2
PPTX
Code camp 2011 Getting Started with IOS, Una Daly
PDF
iOS 101 - Xcode, Objective-C, iOS APIs
PDF
Leaving Interface Builder Behind
KEY
Iphone os dev sharing with new examples
PPT
Programming iOS in C#
PDF
Session 15 - Working with Image, Scroll, Collection, Picker, and Web View
PPTX
Basic iOS Training with SWIFT - Part 3
PDF
FI MUNI 2012 - iOS Basics
PDF
MFF UK - Introduction to iOS
PDF
CoconutKit
PDF
Assignment2 B Walkthrough
PPTX
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
08 objective-c session 8
iPhone dev intro
Beginning to iPhone development
Assignment 4 Paparazzi1
iOS Development (Part 3) - Additional GUI Components
My Favourite 10 Things about Xcode/ObjectiveC
Paparazzi2
Code camp 2011 Getting Started with IOS, Una Daly
iOS 101 - Xcode, Objective-C, iOS APIs
Leaving Interface Builder Behind
Iphone os dev sharing with new examples
Programming iOS in C#
Session 15 - Working with Image, Scroll, Collection, Picker, and Web View
Basic iOS Training with SWIFT - Part 3
FI MUNI 2012 - iOS Basics
MFF UK - Introduction to iOS
CoconutKit
Assignment2 B Walkthrough
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1

iOS Training Session-3

  • 2. iOS Application Development -Hussain KMR Behestee The Jaxara IT LTD. [Session-3]
  • 3. Agendas ∗ Programming with Segue ∗ Dynamic design through coding ∗ Views and its Co-ordinates ∗ Core animations ∗ Picture pickers ∗ Sound manager ∗ Address book picker
  • 4. Programming with Segue Segue in Storyboarding
  • 6. Programming with Segue Life Cycle of Segue ∗ Your app never creates segue objects directly, they are always created on your behalf by iOS when a segue is triggered. ∗ The destination controller is created and initialized. ∗ The segue object is created and its initWithIdentifier:source:destination: method is called. The identifier is the unique string you provided for the segue in Interface Builder, and the two other parameters represent the two controller objects in the transition. ∗ The source view controller’s prepareForSegue:sender: method is called. ∗ The segue object’s perform method is called. This method performs a transition to bring the destination view controller on-screen. ∗ The reference to the segue object is released, causing it to be deallocated.
  • 7. Programming with Segue Triggering a segue programmatically - (void)orientationChanged:(NSNotification *)notification { UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; if (UIDeviceOrientationIsLandscape(deviceOrientation) && !isShowingLandscapeView) { [self performSegueWithIdentifier:@"DisplayAlternateView" sender:self]; isShowingLandscapeView = YES; } }
  • 8. Dynamic design through coding UIView's frame: The CGPoint: The CGSize : struct CGRect struct CGPoint struct CGSize { CGPoint origin; { CGFloat x; CGFloat { CGFloat width; CGSize size; }; y; }; CGFloat height; }; [button setFrame:CGRectMake(x, y, width, height)];
  • 10. Dynamic design through coding ∗ Creating UI Object on the fly UIImageView* campFireView = [[UIImageView alloc] initWithFrame: self.view.frame]; campFireView.image = [UIImage imageWithName:@"image.png"]; ∗ Adding to view [self.view addSubview: campFireView];
  • 11. Core animations ∗ View Based Animation [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.8]; //animation logic here [UIView commitAnimations]; ∗ Set animation complete callback [UIView setAnimationDidStopSelector: @selector(onAnimationComplete:finished:context:)]; ∗ onAnimationComplete – Callback - (void)onAnimationComplete:(NSString *)animationID finished: (NSNumber *)finished context:(void *)context
  • 12. Core animations ∗ Image Based Animation ∗ create the view that will execute our animation UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame]; ∗ load all the frames of our animation campFireView.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"campFire01.gif"], [UIImage imageNamed:@"campFire02.gif"], nil]; campFireView.animationDuration = 1.75; ∗ repeat the annimation forever campFireView.animationRepeatCount = 0; ∗ start animating [campFireView startAnimating]; ∗ add the animation view to the main window [self.view addSubview:campFireView];
  • 13. Picture pickers Initialization.. ∗ Initialize the Image Picker and set delegate for interaction picker = [[UIImagePickerController alloc] init]; picker.delegate = self; ∗ Checking and setting Source type if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ picker.sourceType = UIImagePickerControllerSourceTypeCamera; } else{ picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; } ∗ Call the picker to front [self presentViewController:picker animated:YES completion:NULL];
  • 14. Picture pickers Grabbing the image ∗ If the user cancels we just dismiss the picker and release the object - (void)imagePickerControllerDidCancel:(UIImagePickerController *) Picker { [[picker presentingViewController] dismissViewControllerAnimated:YES completion:NULL]; } ∗ But if the user selects an image or takes a photo with the camera (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ { selectedImage.image = [info objectForKey:UIImagePickerControllerOriginalImage]; [[picker presentingViewController] dismissViewControllerAnimated:YES completion:NULL]; } ∗ For more information
  • 15. Sound manager ∗ Get the main bundle for the app CFBundleRef mainBundle = CFBundleGetMainBundle (); ∗ Get the URL to the sound file to play CFURLRef soundFileURLRef; soundFileURLRef = CFBundleCopyResourceURL ( mainBundle, CFSTR ("tap"), CFSTR ("aif"), NULL); ∗ Create a system sound object representing the sound file SystemSoundID soundFileObject; AudioServicesCreateSystemSoundID (soundFileURLRef, &soundFileObject);
  • 16. Sound manager ∗ For System Sound Play AudioServicesPlaySystemSound (soundFileObject); ∗ For Alert Sound Play AudioServicesPlayAlertSound (soundFileObject); ∗ For Vibrate Play AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
  • 17. Address book picker ∗ Add Framework: AddressBookUI, AddressBook ∗ Add Header File: #import <AddressBookUI/AddressBookUI.h> ∗ Add Protocol : ABPeoplePickerNavigationControllerDelegate ∗ Responding to User Events ∗ peoplePickerNavigationController:shouldContinueAfterSelectingPerson: ∗ peoplePickerNavigationController:shouldContinueAfterSelectingPerson:pro perty:identifier: ∗ peoplePickerNavigationControllerDidCancel: