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

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)