1.点击tableView空白处隐藏键盘
UITapGestureRecognizer *tableViewGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tableViewTouchInSide)];
tableViewGesture.numberOfTapsRequired = 1;//几个手指点击
tableViewGesture.cancelsTouchesInView = NO;//是否取消点击处的其他action
[self.tableView addGestureRecognizer:tableViewGesture];
- (void)tableViewTouchInSide{
[self.view endEditing:YES];
}
2.UITableView直接定位到指定位置
- viewDidLoad里面
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:number] atScrollPosition:UITableViewScrollPositionTop animated:YES];
});
- viewDidAppear里面
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:number] atScrollPosition:UITableViewScrollPositionTop animated:YES];
第一种效果好一点,第二种晃动明显
三 没有导航栏或者tabbar的时候 全界面添加view
nav:[self.navigationController.view addSubview:self.statuaView];
tabbar:[self.tabBarController.view addSubview:self.statuaView];