In iOS, the way to hide search results by clicking Search results.

Source: Internet
Author: User

Do not know if there is anything else good way, recently in implementing a demand (click Search, then enter search content, show the results of the search, and then click on the search results, in the current page to display the results of the click of the detailed information). The problem is that when you click on the search results, the results of the search are not hidden, so you can't see what's blocking it.

The solution is

For (ID view in subviews) {

if ([View Iskindofclass:[uibutton class]]) {

UIButton *cancelbutton = (UIButton *) view;

[CancelButton settitle:@ "Cancel" forstate:uicontrolstatenormal];

Gets the response event that hits the "Cancel" button (Actionsfortarget This method returns an array)

self.cancelsearchselstring = [[CancelButton actionsfortarget:mysearchbar forcontrolevent: UIControlEventTouchUpInside] objectatindex:0];

Response notification, run the method directly with the response event method obtained above, conversion (this is a knowledge point, can be extended under)

[[Nsnotificationcenter Defaultcenter] Addobserver:mysearchbar selector:nsselectorfromstring ( self.cancelsearchselstring) name:@ "Cancelsearch" object:nil];

}

}

Then in the Click event

[[Nsnotificationcenter Defaultcenter] postnotificationname:@ "Cancelsearch" object:nil];

Announce---response---cancellation notice

[[Nsnotificationcenter Defaultcenter] Removeobserver:mysearchbar name:@ "Cancelsearch" object:nil];

On the line.

In iOS, the way to hide search results by clicking Search results.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.