2023年7月13日发(作者:)
UISearchController使⽤中遇到的各种问题⾸先初始化,这就不细说了,三个代理都写上: _ResultsUpdater = self; _te = self; _te = self;⼀、⾃动弹出键盘以往的写法:- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; = true;}- (void)didPresentSearchController:(UISearchController *)searchController { [Bar becomeFirstResponder];}实现如上的代码就可以了,但是如果把searchbar写到导航条上,发现这么写完全是没作⽤的。修改:- (void)didPresentSearchController:(UISearchController *)searchController { [UIView animateWithDuration:0.1 animations:^{} completion:^(BOOL finished) { [Bar becomeFirstResponder]; }];}⼆、搜索输⼊时禁⽌searchBar上移隐藏导航条 _avigationBarDuringPresentation = NO;三、修改searchBar取消按钮的颜⾊和⽂字 [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTintColor:[UIColor whiteColor]]; [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTitle:@"取消"];四、显⽰searBar的光标(如果不显⽰可以这么设置) _lor = [UIColor blueberryColor];
发布者:admin,转转请注明出处:http://www.yc00.com/web/1689262636a226330.html
评论列表(0条)