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];
本文详细介绍了如何使用SwiftUI构建响应迅速、视觉效果出众的iOS应用程序。从环境搭建、界面设计到交互逻辑实现,一步步带领读者掌握SwiftUI核心概念与技巧。文章还分享了提高开发效率的实用小贴士,以及如何利用SwiftUI进行适配和优化,确保应用在不同设备上都能拥有最佳体验。
172

被折叠的 条评论
为什么被折叠?



