UISearchDisplayController shadow frame Adjustment

Source: Internet
Author: User

When the UISearchDisplayController and UISearchBar in iOS7 are used together, sometimes the search box gets the focus, and the shaded part blocks the search box, which affects user usage, as shown in figure

{

   for(UIView * v in controller.searchResultsTableView.superview.subviews)    {        NSLog(@"%@",[v class]);        if([v isKindOfClass:NSClassFromString(@"_UISearchDisplayControllerDimmingView")])        {            v.frame = CGRectMake(0,20,320,400); //        }    }

}

3. After modifying the code above, the mask layer does not block the search box, but you still find that the focus cannot be obtained in the lower area of the search box, And the Cancel button is not easy to use.

4. You can see from the previous figure that although the mask layer goes down, there is still a layer blocking. In the left list, this layer is displayed as the parent view of searchResultsTableView and the code is modified again.

- ()searchDisplayControllerWillBeginSearch:(UISearchDisplayController *= CGRectMake(,,,(UIView * v ,[v ([v isKindOfClass:NSClassFromString(= CGRectMake(,,,); 

5. Solve the Problem and use the search box properly.

) SearchDisplayController :( UISearchDisplayController *) controller didShowSearchResultsTableView :( UITableView * = CGRectMake (, 320,480 --

7. After multiple tests, it is found that the first execution is invalid because searchDisplayControllerWillBeginSearch is null during the first execution and is not added to the parent view. Two solutions can be used.

Solution 1: delayed execution:

- ()searchDisplayControllerWillBeginSearch:(UISearchDisplayController *- (== (offset == =CGRectMake(,,,(UIView * v ,[v ([v isKindOfClass:NSClassFromString(= CGRectMake(,,,); 

Solution 2: register the keyboard notification:

- (- (- (== (offset == =CGRectMake(,,,(UIView * v ,[v ([v isKindOfClass:NSClassFromString(= CGRectMake(,,,); 

 

Solve the problem!

Note: The above frame adjustment is executed on ios7 and is not required in versions earlier than ios7.

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.