日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

How do I cover the “no results” text in UISearchDisplayController's searchResultTableView?

發布時間:2025/7/25 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 How do I cover the “no results” text in UISearchDisplayController's searchResultTableView? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

How do I cover the “no results” text in UISearchDisplayController's searchResultTableView?


I don't want to show the "no results" text while my server is processing a search query.

I figured out the exact coordinates of the table cell that contains the label and attempted to cover it.

self.noResultsCoverView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 44.0, 320.0, 43.0 )] autorelease]; self.noResultsCoverView.backgroundColor = [UIColor whiteColor]; [self.searchDisplayController.searchResultsTableView addSubview:self.noResultsCoverView];

To my chagrin, my cover was above the table view, but below the label. I need the cover to be above the label.?searchResultsTableView::bringSubviewToFront?didn't work, which makes me believe that the label isn't a child of the?searchResultsTableView?at all.

BTW, this?Stack Overflow answer?doesn't quite work for me. It works on the very first search, but flashes a weird black cover on subsequent searches.

this should do the work properly. The code to return at least one cell:

BOOL ivarNoResults; // put this somewhere in @interface or at top of @implementation - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {if (tableView == self.searchDisplayController.searchResultsTableView) {if (filteredList.count == 0) {ivarNoResults = YES;return 1;} else {ivarNoResults = NO;return [filteredList count];}}// {…}// return the unfiltered array count }

and for "showing" the clean cell:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {if (tableView == self.searchDisplayController.searchResultsTableView && ivarNoResults) {static NSString *cleanCellIdent = @"cleanCell";UITableViewCell *ccell = [tableView dequeueReusableCellWithIdentifier:cleanCellIdent];if (ccell == nil) {ccell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cleanCellIdent] autorelease];ccell.userInteractionEnabled = NO;}return ccell;}// {…} }
share|improve this answer answered?Aug 2 '12 at 8:39 relikd
7,48541956
? ?
up vote0down vote

You need to realize that when you have a?UISearchDisplayController, and the search bar is active, the?UITableView?argument passed into your?UITableView?data source and delegate methods is in fact NOT your tableView object, but a tableView managed by theUISearchDisplayController, intended to display "live" search results (perhaps results filtered from your main data source, for example).

You can easily detect this in code, and then return the appropriate result from the delegate/data source method, depending on which tableView object is asking.

For example:

- (NSInteger)tableView:(UITableView *)tv numberOfRowsInSection:(NSInteger)section {if (tv == self.searchDisplayController.searchResultsTableView) {// return the number of rows in section for the visible search results.// return a non-zero value to suppress "No results"} else {// return the number of rows in section for your main data source} }

The point is that your data source and delegate methods are serving?two?tables, and you can (and should) check for which table is asking for data or delegation.

By the way, the "No results" is (I believe) provided by a background image which theUISearchDisplayController?displays when the delegate says there are no rows... You are not seeing a 2-row table, the first blank and the second with text "No results". At least, that's what I think is happening there.

share|improve this answer answered?Jul 27 '12 at 19:53 MarkGranoff
10.2k2338
? ?
up vote0down vote

I haven't tried it myself, you can give it a try--?Link

Regards,?
Amar

share|improve this answer answered?Jul 30 '12 at 3:44 Amar
961214
? ?
因為產生的UILabel@“No Resulte”有延遲,如果不延遲檢測是檢測不出來的
up vote-2down vote

Try this it worked for me

In the UISearchDisplayController delegate do this:=

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.001);dispatch_after(popTime, dispatch_get_main_queue(), ^(void){for (UIView* v in self.searchDisplayController.searchResultsTableView.subviews) {if ([v isKindOfClass: [UILabel class]] && [[(UILabel*)v text] isEqualToString:@"No Results"]) {[(UILabel*)v setText:@""];break;}}});return YES; }

版權聲明:本文為博主原創文章,未經博主允許不得轉載。

轉載于:https://www.cnblogs.com/zsw-1993/p/4879967.html

總結

以上是生活随笔為你收集整理的How do I cover the “no results” text in UISearchDisplayController's searchResultTableView?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 天天艹天天 | 久久亚洲电影 | 中文字幕高清在线播放 | 国产无套粉嫩白浆内谢 | 午夜av一区二区 | 手机在线永久免费观看av片 | 精品无码在线视频 | 欧美黄色高清视频 | 插吧插吧网 | 99色在线| www欧美com| 色综合婷婷 | 污视频免费在线 | 精品欧美乱码久久久久久1区2区 | 极品美妇后花庭翘臀娇吟小说 | 成人午夜免费观看 | 免费看的黄网站 | 四虎影裤 | 国产精品精品国产 | 中文在线字幕免费观 | 婷婷伊人综合中文字幕 | av综合网站 | 婷婷九月综合 | www.九色| 国产白丝一区二区三区 | 国模吧一区二区三区 | 久久久久麻豆 | 免费一二三区 | 五月婷婷综合色 | 成人欧美日韩 | 免费无遮挡在线观看视频网站 | 午夜免费看 | 日韩人妻精品无码一区二区三区 | 欧美性猛交xxx乱大交3蜜桃 | 亚洲熟妇无码久久精品 | 成人免费视频大全 | 蜜臀精品一区二区三区 | 尤物网站在线播放 | 亚洲成人视屏 | 久久98| 亚洲一区二区三区成人 | 1级片在线观看 | 亚州国产精品 | 岛国免费视频 | 免费亚洲一区二区 | 黄色特级网站 | 国产一区精品视频 | aaaaa级少妇高潮大片免费看 | 日本精品人妻无码免费大全 | 日本人的性生活视频 | 黄色av免费在线 | 三年大全国语中文版免费播放 | 日韩精品五区 | 国产一区二区三区黄片 | 中文字幕在线观看一区二区 | 国产色婷婷一区二区三区竹菊影视 | 天天天天天天天干 | 三级av网| 欧美天天爽 | 日韩精品导航 | 理论av| 亚洲黄色一级大片 | 久草手机在线观看 | av激情小说| 中文字幕中文字幕 | 91精品久久人妻一区二区夜夜夜 | 日韩精品免费一区二区三区竹菊 | 亚洲免费看片 | 日本不卡一区 | 国产国语性生话播放 | 亚洲国产精品成人午夜在线观看 | 欧美一区二区三区成人 | 99re久久| 久久午夜精品人妻一区二区三区 | 成人免费aaa| 日本激情网址 | а√中文在线资源库 | 中文字幕av影院 | 美女福利在线视频 | 亚洲国产精品无码久久久 | 亚洲欧洲精品一区二区三区 | 激情播播网 | 狠狠操女人| 久久久综合视频 | 国产欧美精品一区二区三区 | www国产精品视频 | 欧美丰满少妇 | 久久成人福利 | 亚洲精品免费在线观看视频 | 销魂美女一区二区 | 成年人免费毛片 | 男人天堂网av | 亚洲一本在线 | 九色国产精品 | 久久91精品国产91久久小草 | 劲爆欧美第一页 | 51ⅴ精品国产91久久久久久 | 亚洲精品美女久久久 | 欧美天天爽 |