Review 06- iOS notification mechanism diary, listen for keyboard, additional properties [2020]

preamble:

Before learning through knowledge, write a little demo qq chat
mainly pure code layout tableview based, after all, they can not engage in dynamic xib thing
this diary, I only recorded for attention

text

First typedef enum {} xxx; enumeration defines a message
because data can only be set as a group, the group 1 is directly returned to it
. Each cell can not be given Geken xib achieved, the size of the code is purely dynamic manner
is obtained high screen: uiscreen mainscreen] .bounds.size.width
should be noted that the pop-up keyboard to pan up tableview need to avoid overwriting
? how to listen to events do need to use the keyboard notification mechanism

Notification mechanism

For the keyboard of this global affairs, can not be used to listen for the event, notice need
can benefit the whole class to send the notification, after communicating with each other, the keyboard pops up, ios pop-up message will be sent to
any class is listening, tell he these types of information, if you do not want to listen to listen directly out of it.
we can also customize your own notice

Published notice:
---- need to publish / listeners need NSNotificationCenter objects
---- NSNotification package is a notification each time a notification is sent you this object.
---- NSNotification of property: name, object, userinfo
by class methods to get the global object NSNotificationCenter get a single embodiment
[NSNotificationCenter defaultCenter]
use get the object method
postNotificationName: "Notify name" object: Object transmitted (write who hair who)
the userInfo: @ { "key ":"value"}

Monitor notifications:
get NSNotificationCenter this object
- use addObserver: listener objects selector: SEL (to monitor the implementation of sel) name: inform the name of object: Object
If you want to add a reference sel, write NSNotification parameter
objects inside: Notification name name, notification object: object, object dictionary information: userinfo
additional:
If the listener does not monitor objects to write, who made the notification will be listening to the same name
if the name is also written notice nil, the global notification can receive ...

Removal notification
------ rewriting - (void) dealloc removed when the class is not directed (otherwise the program will jump)
------ get NSNotificationCenter object execution method removeObserver: Who removed objects

Keyboard monitor notice

NSNotificationCenter create objects
using object methods addObserver add notification listener named:
UIKeyboardWillShowNotification to be ejected
UIKeyboardDidShowNotification been ejected
UIKeyboardWillHideNotification will be hidden
UIKeyboardDidHideNotification, has been hidden
. UIkeyBoardWillChangeFrameNotification about to change keyboard size
is a constant, not with "" the
object parameter does not need to know who released ... listening on the bin
parameter object to accept NSNotification specific content depends on your monitor name the
dictionary information within the dimensional change monitor of the keyboard. to get beyond the keyboard pop-rect, you can do whatever the
translation, then reset the transform on the line
CGAffineTransformMakeTranslation

Notification mechanism of my shallow understanding nonsense:
If you come into contact with mcserver plug-in development, mechanisms and event notification almost feel ...
but the event ios in is a separate event, such as a button click event, it can not be transmitted globally.
Not who want to listen can listen ... create button to set the time of this incident fixed
right, and almost callback. or execute the same code block internal like.

New Properties

tableview.allowsSelection can set the selected
image strectchableImageWithLeftCapWidth: topCapHeight:
drawing pictures with a tiled manner, two parameters are retained where to begin
general is half of the left half of the height, so that four weeks to retain, cut from the middle point of the smallest tiles. . on the line
padding contentEdgeInsets the settings button
if you want to set the text box to the left of the display uiview, .leftview so it can engage in margin curve
must be set leftviewmode enumeration is always displayed, otherwise no effect
default is to have this textfield unless you want to remove the default property of the border property
listens text box is sent, the quasi-Shou text box protocol
- (bool) textfieldShouldReturn this method on the line
to get the current system time is not written to explain this very basic
NSDate * nowDate = [NSDate DATE];
NSDateFormateer Formatter * = [[NSDateFormateer the alloc] the init];
formatter.dateformat = "time HH: mm";
NSString Ti = [Formatter stringFromDate: nowDate];

Published 15 original articles · won praise 0 · Views 2563

Guess you like

Origin blog.csdn.net/u014270781/article/details/105190916