在一个modal出来的vc上,再次modal一个vc2,vc2里有这个searbar不知道为啥就有这个bug(viewdidload方法里加入到vc2的view里)
后来改成如下代码 算是一个比较笨的解决方案
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.headView addSubview:self.searchBar];
self.searchBar.frame = CGRectMake(0, 20, kDeviceWidth, self.headViewHeight - 20);
self.searchBar.text = _keyWord;
[self.searchBar becomeFirstResponder];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.searchBar resignFirstResponder];
[self.searchBar removeFromSuperview];
}
网友评论