cocoa touch - Move view when so that keyboard does not hide text field -


in app, when click on text field, keyboard hides it. please me -- how can move view when click on text field. i'm using code in textfielddidbeginediting:

self.tableview.scrollindicatorinsets = uiedgeinsetsmake(0, 0, 216, 0); self.tableview.contentinset = uiedgeinsetsmake(0, 0, 216, 0); 

but doesn't work.

you can following, first make sure you've set uitextfield delegate self and

#define koffset_for_keyboard 350; 

at top. how far want view shifted

//method move view up/down whenever keyboard shown/dismissed  -(void)setviewmovedup:(bool)movedup {     [uiview beginanimations:nil context:null];     [uiview setanimationduration:0.3]; // if want slide view     [uiview setanimationbeginsfromcurrentstate:yes];      cgrect rect = self.view.frame;     if (movedup)     {         // 1. move view's origin text field hidden come above keyboard          // 2. increase size of view area behind keyboard covered up.          if (rect.origin.y == 0 ) {             rect.origin.y -= koffset_for_keyboard;             //rect.size.height += koffset_for_keyboard;         }      }     else     {         if (stayup == no) {             rect.origin.y += koffset_for_keyboard;             //rect.size.height -= koffset_for_keyboard;         }     }     self.view.frame = rect;      [uiview commitanimations]; }   - (void)keyboardwillhide:(nsnotification *)notif {     [self setviewmovedup:no]; }   - (void)keyboardwillshow:(nsnotification *)notif{     [self setviewmovedup:yes]; }   - (void)textfielddidbeginediting:(uitextfield *)textfield {     stayup = yes;     [self setviewmovedup:yes]; }   - (void)textfielddidendediting:(uitextfield *)textfield {     stayup = no;     [self setviewmovedup:no]; }  - (void)viewwillappear:(bool)animated {     [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(keyboardwillshow:)                                                   name:uikeyboardwillshownotification object:self.view.window];     [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(keyboardwillhide:)                                                   name:uikeyboardwillhidenotification object:self.view.window]; }  - (void)viewwilldisappear:(bool)animated {     // unregister keyboard notifications while not visible.     [[nsnotificationcenter defaultcenter] removeobserver:self name:uikeyboardwillshownotification object:nil];     [[nsnotificationcenter defaultcenter] removeobserver:self name:uikeyboardwillhidenotification object:nil]; } 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -