我显示一个 UITView, 并加载搜索栏和范围栏按钮。 当用户点击范围栏按钮时, 键盘会显示, 搜索栏会获得焦点( 成为第一个响应器 ) 。
允许使用范围栏按钮过滤表格项目而不显示键盘的可能性吗? 用户可以通过在搜索文本条目字段中专门点击来让键盘出现。
我显示一个 UITView, 并加载搜索栏和范围栏按钮。 当用户点击范围栏按钮时, 键盘会显示, 搜索栏会获得焦点( 成为第一个响应器 ) 。
允许使用范围栏按钮过滤表格项目而不显示键盘的可能性吗? 用户可以通过在搜索文本条目字段中专门点击来让键盘出现。
最后,我的解决方案涉及使用两种代表方法和查看控制器上的状态变量。
在查看控制器上我添加了属性
NSNumber *scopeButtonPressedIndexNumber;
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
if (self.scopeButtonPressedIndexNumber != nil) {
self.scopeButtonPressedIndexNumber = nil; //reset
return NO;
}
else {
return YES;
}
}
- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope {
self.scopeButtonPressedIndexNumber = [NSNumber numberWithInt:selectedScope];
}
从本质上讲,我捕捉到是否按下范围按钮,如果是这样的话,我在“应该开始编辑”中返回了“否”。这样,我就能阻止焦点进入搜索栏。
当然。 执行取决于您如何设置您的 UITable View, 但是假设您使用 NSFededResults 主计长, 您可以做到这一点 :
1) 假设您有三个范围栏按钮; 创建 4 个 NSFRC 。
2) 为前3个NSFRC建立检索请求,每个请求都有前提,仅选择相应的范围栏按钮的相关范围。
3) 使用最后的 NSFRC 搜索功能。请查看 Brent Piddy s spost on < a href="https://stackoverflow.com/ questions/4471289/how-to- filter-nsfleted results controller-coredata- with- uisearchdisplaycontrol">如何用 UISearch Display 主计长/UISearchBar < /a> 来过滤 NSFletedResults 主计长(CoreData), 了解您尚未进行搜索时如何进行搜索的细节 。
4) 当用户按下范围栏按钮时, < 坚固 > 不将任何文字写入搜索栏, 而是在相关的 NFC 中进行交换。 突出显示按钮( 或考虑使用 UISioned Control), 以便用户能够看到它们正在查看的范围 。
(5) 当用户将文本输入搜索栏时, 请按上文布伦特的文章中的详细内容, 在搜索栏中交换 NSFRC 。 删除按钮或 UISioned Control 上的任何突出显示, 并在屏幕上保留搜索栏, 这样他们就可以再次看到他们正在查看的范围 。
For a basic app with nonconsumable in-app purchases, has anyone figured out best practices for using SKPaymentQueue s restoreCompletedTransactions? Observations I know it s recommended to always ...
I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...
I have a UITextField that is a subview of a UITableViewCell. When my view loads, I want the text field to become first responder. I have a pointer to the text field in the table cell, so to do this I ...
I ve been working on adding in-app purchases and was able to create and test in-app purchases using Store Kit (yay!). During testing, I exercised my app in a way which caused the app to crash mid ...
In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...
Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...
I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...
Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...