UISearchBar在横向时不响应,但在iPad上纵向时响应良好
||
我正在处理关于UISearchBar的应用程序中的错误。
使用代码:
int width = 250;
searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(768 - width - indent, companySelectionButton.frame.origin.y + (companySelectionButton.frame.size.height - 44)/2, width, 44)];
[searchBar setAutoresizingMask: UIViewAutoresizingFlexibleLeftMargin];
[searchBar setPlaceholder:[Globals localisedString:@\"Search by Code or Name\"]];
[searchBar setAutocorrectionType:UITextAutocorrectionTypeNo];
[searchBar setDelegate:self];
[self.view addSubview:searchBar];
[searchBar release];
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
搜索栏在两个方向上都位于我想要的位置,但是它不会响应横向上的水龙头,而是成为第一响应者/显示键盘。
我尝试注释掉以下几行,以查看是否有帮助,但不能解决问题:
[searchBar setAutoresizingMask: UIViewAutoresizingFlexibleLeftMargin];
[[searchBar.subviews objectAtIndex:0] removeFromSuperview];
还有其他人有类似的问题吗?
提前致谢 :)
编辑
注释掉后[searchBar setDelegate:nil];搜索栏可以在所有方向上成为第一响应者。但是,当然,我需要一个委托人才能使用搜索栏!有任何想法吗???会继续发挥作用,也许我缺少某种委托方法?
没有找到相关结果
已邀请:
2 个回复
锑寝粒
芜任亮蜡