您的位置:首页 > 移动开发 > IOS开发

ios 如果获取cell上控件相对于屏幕的坐标

2016-12-13 14:29 1086 查看
UIWindow * window=[[[UIApplication sharedApplication] delegate] window];
CGRect frame=[self convertRect: self.bounds toView:window];


textfield不被键盘遮挡

UIWindow * window=[[[UIApplication sharedApplication] delegate] window];
CGRect frame=[self convertRect: self.bounds toView:window];
int offset = frame.origin.y+90 - (SCREEN_HEIGHT - 216.0);//iPhone键盘高度216,iPad的为352

[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
[UIView setAnimationDuration:0.5f];

//将视图的Y坐标向上移动offset个单位,以使下面腾出地方用于软键盘的显示
if(offset > 0)
self.controller.view.frame = CGRectMake(0.0f, -offset, SCREEN_WIDTH, self.controller.view.frame.size.height);
self.controller.submitBtn.frame =CGRectMake(0, SCREEN_HEIGHT -50+100, SCREEN_WIDTH , 50);
[UIView commitAnimations];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios