objective c - how to handle key events in iphone -
hi working on iphone application , want handle keyboard events in iphone. in mac, there class nsevent handles both keyboard , mouse events, , in ios (iphone/ipad) counterpart of nsevent uievent handles touch events. know ios api not provide functionality, how can handle key events in iphone??? tutorial or sth, started...
you cant directly code keyboad;s key , there no mouse in case of device.
you can make logics different kind of charectersets or can make logics in textfield delgate methods or textview delegates method
textview delegate
- (bool)textview:(uitextview *)textview shouldchangetextinrange:(nsrange)range replacementtext:(nsstring *)text
textfield delegate
- (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string
you can use notification textfield , textview.
for textfield use this
call register method in viewdidload
-(void)registerfortextfieldnotifications { nsnotificationcenter *notificationcenter = [nsnotificationcenter defaultcenter]; [notificationcenter addobserver:self selector:@selector (handle_textfieldtextchanged:) name:uitextfieldtextdidchangenotification object:self.textfield]; } - (void) handle_textfieldtextchanged:(id)notification { if([isinappobj.passcodestring isequaltostring:locktextfield.text]) { //code here } }
and text view need change event name this
[notificationcenter addobserver:self selector:@selector (handle_textfieldtextchanged:) name:uitextviewtextdidchangenotification object:self.textfield];
Comments
Post a Comment