قالب وردپرس درنا توس
Home / IOS Development / # 282: Taming keyboard with typist ⌨️ – Little Bites of Cocoa

# 282: Taming keyboard with typist ⌨️ – Little Bites of Cocoa



Subjects

Topics

Correctly Responds to Integration with the Software Keyboard is a major part of building a solid iOS app . Traditionally, this will mean observing NSNotificationCenter notifications and some quite long boilerplate codes. Today we look at a great little library from Toto Tvalavadze called Typist who can improve all this. Typist Typist Typist Typist Typist Typist Typist . shared
on ( arrangement . didShow ). { ( alternatives [1

9659013]) in
// TODO
}
. start ()
}

Yep. That's it. Note: We are not required to use Typist's singleton instance, but it is provided for convenience.)

Typist provides the same interface for a bunch of useful events ]:

  Typist .   split 
  .   at   [ ] [ ] : [
  ] ] 
  ]    [ ]    / [TODO*/[19659049]] 
         : 
   . ) )    {     in    / * TODO * /  } 
  .   on [19659013] [] :  .   willHide )    {     i    / * TODO * /  } 
     at   (  [] ]  .   196 59019]} 
     on   (  the arrangement .     willChangeFrame ).              ] 
   
     on   (  event :  .   didChangeFrame )    {19659046] 19659023] in    / * TODO * /  } 
  .   start   () 
} 

Finally, in each event ] is given a Typist.KeyboardOptions type containing highly typed properties describing the event :

  Typist .   split  .   on   (  arrangement .     willShow [19659018])    {   (  alternatives )    in [19659135] cover   alternatives .   belongsToCurrentApp    otherwise    {   return  } 

      updateLayout   (  for :   alternatives     endFrame  ] 
   
     on   (  the arrangement .:   [19659010] willHide )    {   (  the options  )    in 
      guard   the options .   belongsToCurrentApp    other    {   return  }   updateLayout   (  to .   alternatives     endFrame  ). 
        start   () 
} 

Here we are guard – to ensure that the keyboard belongs to our app and back early if not.

Then we use endFrame the property to adjust our own views to accommodate the keyboard .

19659006] Typist's alternatives type also provides startFrame animationCurve and animationDuration features to help us compare animation of the app to the keyboard .

Learn more about Typist at http: // git.io/typist


Source link