Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOS 7: Overview and Tips/Tricks

iOS 7: Overview and Tips/Tricks

Presentation given at the Houston iPhone Developers Meetup on October 15th 2013.

This session gave a quick overview of the new iOS 7 SDK features, some tips/tricks on features that are often overlooked, and bugs/compatibility issues.

João Prado Maia

October 15, 2013
Tweet

More Decks by João Prado Maia

Other Decks in Programming

Transcript

  1. •  Full  %me  contract  iOS  developer  out  of  The  Woodlands

      •  Contact  me  at  [email protected]   •  Founder/Organizer  of  Houston  iPhone  Developers  Meetup   •  Organizer  of  Houston  PHP  Users  Group   •  Personal  iPhone  apps  on  store  since  2008   •  Personal  site  at  hJp://pessoal.org   2 iOS  7  :  Overview  and  Tips/Tricks Who?  
  2. •  Overview  of  new  features  on  iOS  7   • 

    Bugs,  compa%bility  issues,  etc   •  Tips  and  tricks   •  ORen  overlooked  features   3 iOS  7  :  Overview  and  Tips/Tricks Tonight’s  session  
  3. •  Mixpanel  providing  a  detailed  chart  of  adop%on  rate  

    •  hJps://mixpanel.com/trends/#report/ios_7   •  Current  breakdown:   •  iOS  7  –  71%   •  iOS  6  –  25%   •  Other  –  4%   4 iOS  7  :  Overview  and  Tips/Tricks iOS  7  adopIon  
  4. •  Best/easiest  op%on  is  to  make  apps  iOS  7+  

    •  App  Store  now  allows  users  with  older  devices  to  download  old  versions  of   your  apps.   •  If  you  can’t  avoid  doing  iOS  6  apps,  we  will  discuss  some  bugs  /  compa%bility   issues.   5 iOS  7  :  Overview  and  Tips/Tricks Moving  forward  
  5. •  Text  Kit   •  Dynamic  Type   •  Sprite

     Kit  framework   •  Game  Controller  framework   •  Mul%peer  Connec%vity  framework   •  MapKit   •  3D  perspec%ve  with  MKMapCamera •  Built  in  support  for  direc%ons  with   MKDirections 6 iOS  7  :  Overview  and  Tips/Tricks Major  new  features   •  AirDrop   •  Mul%tasking  enhancements   •  64-­‐bit  support   •  UIKit  Dynamics   •  OpenGL  ES  3.0   •  iBeacons  
  6. •  Comprehensive  set  of  classes  that  allow  you  to  manage

     text  and  typography.   •  Lays  out  styled  text  into  paragraphs,  columns  and  pages.   •  Easy  to  have  text  flow  around  regions  (such  as  images).   •  More  informa%on   •  hJp://www.raywenderlich.com/50151/text-­‐kit-­‐tutorial   •  Great  tutorial,  even  includes  a  bit  about  Dynamic  Type.   7 iOS  7  :  Overview  and  Tips/Tricks Text  Kit  
  7. •  Allows  user  to  specify  a  system-­‐wide  sehng  of  font/content

     size.   •  Developers  can  support  that  by  using  the  new  APIs.   •  Example:   •  [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline] •  More  informa%on   •  hJps://www.captechconsul%ng.com/blog/john-­‐szumski/ios-­‐7-­‐tutorial-­‐ series-­‐dynamic-­‐type   8 iOS  7  :  Overview  and  Tips/Tricks Dynamic  Type  
  8. •  New  framework  for  making  2D  games,  (very)  similar  to

     Cocos2D,  but  built  in  to   iOS  7.   •  Strong  support  in  Xcode  5  for  par%cles  and  textures.   •  Important  cons  to  men%on   •  Locked  to  iOS  plakorm,  no  support  for  custom  OpenGL  code.   9 iOS  7  :  Overview  and  Tips/Tricks Sprite  Kit  [1]  
  9. •  More  informa%on   •  hJps://developer.apple.com/library/ios/documenta%on/ GraphicsAnima%on/Conceptual/SpriteKit_PG/Introduc%on/ Introduc%on.html   • 

    hJp://www.raywenderlich.com/42699/spritekit-­‐tutorial-­‐for-­‐beginners   •  hJp://www.raywenderlich.com/45152/sprite-­‐kit-­‐tutorial-­‐anima%ons-­‐ and-­‐texture-­‐atlases   •  Lots  more   10 iOS  7  :  Overview  and  Tips/Tricks Sprite  Kit  [2]  
  10. •  Physics  engine  integrated  into  UIKit.   •  Add  behaviors

     to  UIView  objects.   •  Gravity,  aJachments,  forces.   •  More  informa%on   •  hJp://www.raywenderlich.com/50197/uikit-­‐dynamics-­‐tutorial   iOS  7  :  Overview  and  Tips/Tricks UIKit  Dynamics   11
  11. •  dispatch_source_memorypressure_flags_t •  No%fica%on  of  memory  pressure  condi%on  changes  

    •  Used  together  with  GCD’s  dispatch_source_create  and  friends  to  run  some   code  when  condi%ons  change   •  Useful  to  clear  caches  when  necessary,  etc.   •  NSData  has  base  64  encoding/decoding  support  now  (finally).   •  -[NSArray firstObject]  (similar  to  -[NSArray lastObject])   iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  1   12
  12. •  -[NSObject decreaseSize:]  and  –[NSObject increaseSize:] •  Callbacks  for  the

     CMD-­‐  and  CMD+  keyboard  shortcuts   •  Not  super  useful,  but  could  be  used  to  surprise  your  users  in  a  good  way.   •  UISimpleTextPrintFormatter •  Easy  way  to  print  aJributed  strings   •  Old  way  of  doing  this  was  to  render  the  string  into  a  CG  context.   13 iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  2  
  13. •  AVCaptureDeviceFormat •  Video  zooming  feature.   •  Basic  control

     over  frame  rate  and  dura%on.   •  UIScrollView •  -[UIScrollView keyboardDismissMode] •  Easy  to  recreate  the  built-­‐in  Messages  app’s  “scroll  to  dismiss”  keyboard   behavior.   iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  3   14
  14. •  UITextView •  Ability  to  respond  to  tapping  links  with

     - [textView:shouldInteractWithURL:inRange:] •  Ability  to  render  images  inline  with  the  text  as  part  of  its  support  for   NSAttributedString.   •  Can  also  respond  to  touches  on  the  inline  images  with  - [textView:shouldInteractWithTextAttachment:inRange:] iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  4   15
  15. •  MPVolumeView •  -[MPVolumeView wirelessRouteActive]  and  –[MPVolumeView wirelessRoutesAvailable] •  wirelessRouteActive

    - YES  if  a  wireless  route  is  ac%ve.   •  wirelessRoutesAvailable - YES  if  wireless  routes  (AirPlay,  Bluetooth,  etc)  are   available  for  user  selec%on. •  Undocumented  proper%es,  so  look  directly  in  headers  instead  at <MediaPlayer/MPVolumeView.h> iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  5   16
  16. •  MKDistanceFormatter •  Localized  unit-­‐specific  formahng  od  distances.  Pass  CLLocationDistance

      value,  receive  formaJed  string  in  return.   •  Proper  sample  code  available  at  NSHipster   •  hJp://nshipster.com/ios7/   •  NSURLComponents •  No  more  messing  around  with  CFURLCreateStringByAddingPercentEscapes  to   escape  URL  components.   iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  6   17
  17. •  AVSpeechSynthesizer •  Text  to  speech  API,  but  somewhat  limited

     for  now.   •  Ability  to  specify  speed/rate,  pitch,  and  pre/post  delays.   •  Demonstra%on.   •  AJachments  support  on  MFMessageComposeViewController.   •  Already   supported   on   MFMailComposeViewController,   but   now   also   available  for  MMS/iMessage.   iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  7   18
  18. •  JavaScriptCore framework •  “Deep  access  to  the  full  JavaScript

     run%me  from  Objec%ve-­‐C.  You  can   syntax-­‐check  and  execute  scripts,  access  variables,  receive  callbacks,  and   share  Objec%ve-­‐C  objects,  making  possible  a  wide  range  of  interac%ons.”   •  Full  intro  post  available  on  Big  Nerd  Ranch’s  Blog   •  hJp://blog.bignerdranch.com/3784-­‐javascriptcore-­‐and-­‐ios-­‐7/   iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  8   19
  19. •  UIInputView •  Matches  the  appearance  of  the  system  keyboard.

      •  Set  this  as  the  input  view  of  a  responder,  then  add  subviews  to  it.   •  All  subviews  will  get  %n%ng  and  blur  effects  automa%cally  as  needed.   •  AVCaptureMetaDataOutput •  Scan  all  kinds  of  barcodes  (UPC,  QR,  etc)  with  this  class.   •  Example  for  a  QR  code  available  at  NSHipster  (hJp://nshipster.com/ios7/)   iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  9   20
  20. •  SSReadingList •  Available  in  new  SafariServices.framework   •  Super

     easy  way  to  add  an  item  to  Safari’s  Reading  List.   •  Not  a  full  management  API  (also  not  documented),  just  allows  you  to  add  a   new  entry.  Read  more  at  <SafariServices/SSReadingList.h> •  Transparent  table  view  cells  on  iOS  6  and  iOS  7   •  cell.backgroundColor = cell.contentView.backgroundColor = cell.contentView. superview.backgroundColor = [UIColor clearColor]; iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  10   21
  21. •  CTTelephonyNetworkInfo •  Tells  you  what  kind  of  cellular  connec%on

     the  user  is  on  at  that  %me.   •  -[CTTelephonyNetworkInfo currentRadioAccessTechnology] •  No%fica%on  when  cellular  connec%on  changes   •  CTRadioAccessTechnologyDidChangeNotification •  Undocumented,  so  look  at  <CoreTelephony/CTTelephonyNetworkInfo.h>  for   details.   iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  11   22
  22. •  AVPlayer •  Finally  allowing  you  to  change  the  volume

     programma%cally.   •  AVPlayer *player = [AVPlayer playerWithURL:testUrl]; •  player.volume = 0.0f; // muted •  player.volume = 1.0f; // full volume •  You  can  also  check  if  the  player  is  muted  with  a  convenience  method   •  -[AVPlayer muted] iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  12   23
  23. •  Custom  font  sizing  op%ons  in  Dynamic  Text   • 

    -[UIApplication preferredContentSizeCategory] •  Returns  the  content  size  category  that  the  user  has  selected.   •  You  can  use  this  value  to  choose  the  appropriate  size  for  your  font.   •  Regarding  Dynamic  Text,  this  is  an  interes%ng  demo  of  its  features:   •  hJps://github.com/mbigah/BMXContentSizeDemo   iOS  7  :  Overview  and  Tips/Tricks Tips  &  Tricks  13   24
  24. •  Xcode  5  doesn’t  ship  with  a  way  to  build

     iOS  6.x  apps  only  (Base  SDK),  but  there   is  a  solu%on.   •  Work  around:  copy  the  old  4.6.3  Xcode.app’s  iOS  6.1  SDK  over  to  Xcode  5.   •  More  background:   hJp://stackoverflow.com/ques%ons/18423896/is-­‐it-­‐possible-­‐to-­‐install-­‐ios-­‐6-­‐ sdk-­‐on-­‐xcode-­‐5   iOS  7  :  Overview  and  Tips/Tricks Xcode  5  Tip   25
  25. •  UIAlertView •  Contrary  to  what  was  announced  at  WWDC

     2013,  there  is  no  new   contentView  property.   •  hJps://devforums.apple.com/thread/196613?tstart=0   •  Exis%ng  hacks  to  add  subviews  to  UIAlertView  to  display  other  things  in  it   don’t  work  anymore.   •  Alterna%ve:  hJps://github.com/mindbrix/TSAlertView   iOS  7  :  Overview  and  Tips/Tricks Bugs  /  CompaIbility  issues  [1]   26
  26. •  UISearchDisplayController •  Broken  in  all  kinds  of  ways.  

    •  Visual  example:  hJps://twiJer.com/steipete/status/384257813805289472   •  Crazy  hack  to  fix  it:   hJp://petersteinberger.com/blog/2013/fixing-­‐uisearchdisplaycontroller-­‐on-­‐ios-­‐7/   •  -[UIView release]  –  crash  when  dismissed  while  anima%ng   •  Fix  here:   hJp://stackoverflow.com/ques%ons/18945839/uitableview-­‐with-­‐a-­‐ uisearchbar-­‐as-­‐the-­‐header-­‐view-­‐causes-­‐crashes     iOS  7  :  Overview  and  Tips/Tricks Bugs  /  CompaIbility  issues  [2]   27
  27. •  MKMapView •  -[mapView:regionWillChangeAnimated:]  and  -[mapView:regionDidChangeAnimated:]  called   on  iPhone

     upon  viewDidAppear  even  though  the  region  has  not  changed.   •  Annoying  issue  to  work  around.   •  UITableViewCell •  Not  really  a  compa%bility  issue  per  se,  but  the  new  iOS  7  design  for  grouped  table   views  make  each  content  view  320  points  wide,  not  300pt  as  before.   •  You  may  need  to  update  layout  code.   iOS  7  :  Overview  and  Tips/Tricks Bugs  /  CompaIbility  issues  [3]   28
  28. •  UISearchBar •  Sehng  UISearchBar  background  breaks  scope  bar.  

    •  Work  around  here:  hJps://devforums.apple.com/message/905368#905368   •  UIReferenceLibraryViewController •  -[UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:]  returns  YES  on   iOS  7  every  single  %me   iOS  7  :  Overview  and  Tips/Tricks Bugs  /  CompaIbility  issues  [4]   29
  29. •  Keychain  access  on  iOS  7   •  Background  mode

     requires  a  special  (new)  flag  for  keychain  access.   •  More  info:   •  hJps://blog.loom.com/how-­‐we-­‐fixed-­‐the-­‐ios7-­‐forced-­‐logout-­‐bug-­‐thats-­‐ been-­‐plaguing-­‐so-­‐many-­‐apps/   •  hJp://stackoverflow.com/ques%ons/10536859/ios-­‐keychain-­‐not-­‐retrieving-­‐ values-­‐from-­‐background?answertab=votes#tab-­‐top   iOS  7  :  Overview  and  Tips/Tricks Bugs  /  CompaIbility  issues  [5]   30
  30. •  Enable  iOS  7  blur  effect  on  iPad  3:  

    •  [[UIDevice currentDevice] _setGraphicsQualityOverride:0x64] •  Detect  the  new  iPhone  5s  back  plate  color:   •  [[UIDevice currentDevice] _deviceInfoForKey:@"DeviceEnclosureColor"] •  Detect  if  iPhone  is  black/white:   •  [[UIDevice currentDevice] _deviceInfoForKey:@"DeviceColor"] •  Run  Universal  app  in  phone  mode:   •  [[UIApplication sharedApplication] _setIsClassic:YES] Note:  hat  tip  to  @stroughtonsmith  on  these.   iOS  7  :  Overview  and  Tips/Tricks Private  API  hacks   31
  31. •  SWTableViewCell -­‐  implements  a  swippable  content  view  which  exposes

     u%lity   buJons  (similar  to  iOS  7  Mail  Applica%on).   •  hJps://github.com/CEWendel/SWTableViewCell   •  RESideMenu  –  side  menu  with  parallax  effect.   •  hJps://github.com/romaonthego/RESideMenu   •  DAProgressOverlayView  –  download  progress  anima%on  similar  to  app  download.   •  hJps://github.com/daria-­‐kopaliani/DAProgressOverlayView   •  RNFrostedSidebar  –  side  menu  with  blurred  background  and  custom  anima%ons.   •  hJps://github.com/rnystrom/RNFrostedSidebar   iOS  7  :  Overview  and  Tips/Tricks Third  party  libraries   32
  32. •  SSDynamicText -­‐  UILabel/TextField/TextView  subclasses  that  support  custom  fonts  

    with  iOS  7's  dynamic  text  sizes.   •  hJps://github.com/splinesoR/SSDynamicText   •  SDScreenshotCapture  -­‐  captures  a  screenshot  of  the  app  window  which  excludes  the   iOS  status  bar.   •  hJps://github.com/shinydevelopment/SDScreenshotCapture   •  LLDB-­‐QuickLook  -­‐  debugger  command  to  open  images,  views,  etc.   •  hJps://github.com/ryanolsonk/LLDB-­‐QuickLook   •  UIKitResources  –  image  assets  extracted  from  iOS  7.   •  hJps://github.com/youknowone/UIKitResources   iOS  7  :  Overview  and  Tips/Tricks Third  party  libraries  [2]   33
  33. •  iOS  7  wireframe  kit  –  Adobe  Illustrator  kit  to

     make  it  easier  to  build  wireframes.   •  hJps://github.com/blakeperdue/ios7-­‐wireframe-­‐kit   •  OmniGraffle  iOS  7  stencil  pack  ($19.00)   •  hJps://www.graffletopia.com/stencils/1102   •  Glyphish  5  and  6  ($25.00  each)  –  400  icons  that  match  the  new  iOS  7  style.   •  hJp://www.glyphish.com/   iOS  7  :  Overview  and  Tips/Tricks Design  resources   34
  34. •  objc.io  issue  #5  (iOS  7)  -­‐  hJp://www.objc.io/issue-­‐5/   • 

    NSHipster  –  iOS  7  -­‐  hJp://nshipster.com/ios7/   •  iOS  7  API  diffs   •  hJps://developer.apple.com/library/ios/releasenotes/General/ iOS70APIDiffs/index.html#//apple_ref/doc/uid/TP40013203   •  What’s  new  in  iOS   •  hJps://developer.apple.com/library/ios/releasenotes/General/ WhatsNewIniOS/Ar%cles/iOS7.html   35 iOS  7  :  Overview  and  Tips/Tricks More  informaIon  
  35. •  NSScreencast  iOS  7  overview  episode  (free!):   •  hJp://nsscreencast.com/episodes/85-­‐hello-­‐ios-­‐7

      •  WWDC  2013  videos   •  What’s  new  in  Cocoa  Touch  (session  203)   •  Building  User  Interfaces  for  iOS  7  (session  201)   •  Customizing  Your  App’s  Appearance  for  iOS  7  (session  214)   •  ShinobiControls  –  Introducing  iOS  7  Day  by  Day   •  hJp://www.shinobicontrols.com/blog/posts/2013/09/19/introducing-­‐ ios7-­‐day-­‐by-­‐day/   36 iOS  7  :  Overview  and  Tips/Tricks More  informaIon  [2]