objective c - iOS move view above keyboard left black space -
i using uiview button @ bottom of view. want move button right above keyboard when keyboard shows / changes height.
the code using is:
- (void)keyboardframedidchange:(nsnotification *)notification { cgrect keyboardendframe = [[[notification userinfo] objectforkey:uikeyboardframeenduserinfokey] cgrectvalue]; cgrect keyboardbeginframe = [[[notification userinfo] objectforkey:uikeyboardframebeginuserinfokey] cgrectvalue]; cgrect newframe = self.view.frame; cgrect keyboardframeend = [self.view convertrect:keyboardendframe toview:nil]; cgrect keyboardframebegin = [self.view convertrect:keyboardbeginframe toview:nil]; newframe.origin.y -= (keyboardframebegin.origin.y - keyboardframeend.origin.y); self.view.frame = newframe; }
and in viewdidload:
[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(keyboardframedidchange:) name:uikeyboarddidchangeframenotification object:nil];
this code works find on iphone6, if in iphone 5 , using chinese keyboard there black space: