UITableView获取滚动的偏移:
NSLog(@"tableView滚动纵坐标%f",cardTableView.contentOffset.y);
键盘挡住了要输入的view时候,改变view的纵坐标使其适应输入:
//
//将键盘推出时候,view重新回到原来位置
//
-(void)viewKeyboardDisappearChangeRect {
NSTimeInterval animationDuration = 0.30f;
[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
[UIView setAnimationDuration:animationDuration];
//把view设置回默认的Rect
CGRect rect = CGRectMake(0.0, 0, self.view.frame.size.width, self.view.frame.size.height);
self.view.frame = rect;
//cardTableView.frame = rect;
[UIView commitAnimations];
}
//
//view要往上推
//@offset:要推的高度偏移
//
-(void)viewKeyboardAppearChangeRect:(int)offset {
[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
[UIView setAnimationDuration:0.30f];
float width = self.view.frame.size.width;
float height = self.view.frame.size.height;
if (offset > 0) {
//self.view.frame = CGRectMake(0, -offset, width, height);
self.view.frame = CGRectMake(0, -offset, width, height);
}
[UIView commitAnimations];
}