iPad – Why is UISEARCHBAR and its range buttons displayed?

I have seen Apple’s example “TableSearch”. When you touch its scope button, it will appear below the search bar.
http://developer.apple.com/iphone/library/ samplecode/TableSearch/Introduction/Intro.html

However, when I make it myself, it looks good, but when I touch it looks ugly, the scope button and search bar show In the same line, it looks like this:
http://cl.ly/BN9

What should I do to make it look like “TableSearch” in the iPad?

I am doing everything in IB and trying to modify the search bar programmatically from the controller:

- (void)viewDidLoad {

[super viewDidLoad];
self.tableView.rowHeight = 88.0f;
self.tableView.contentOffset = CGPointMake(0, self.searchDisplayController.searchBar.frame.size.height) ;
self.searchDisplayController.searchResultsTableView.rowHeight = self.tableView.rowHeight;


//BELOW DID NOT WORK:
CGRect b = self.searchDisplayController.searchBar .bounds;
self.searchDisplayController.searchBar.bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, self.tableView.rowHeight);
b = self. searchDisplayController.searchBar.frame;
self.searchDisplayController.searchBar.frame = CGRectMake(b.origin.x, b.origin.y, b.size.width, self.tableView.rowHeight);
< br /> //BELOW WORKS PERFECT BUT IS A PRIVATE METHOD, HENCE I AM NOT SUPPOSED TO USE IT
//[self.searchDisplayController.searchBar setCombinesLandscapeBars:NO];
}

Thanks in advance.

I also encountered this Error, I have submitted a report to Apple and asked for technical assistance. I will tell you how it goes. At the same time, I will briefly introduce the bug.

On the iPhone, in order to preserve the precious vertical screen space in landscape mode, UISearchDisplayController sets UISearchBar to combine its search bar and search field in a single horizontal layout. Since the horizontal size of the screen is increased (480 points in landscape), the effect is very good Unfortunately, it doesn’t work very well on the iPad. In landscape mode, you don’t need to change the UI first because you have enough vertical space. In the main view of the UISplitViewController, you still only have 320 pixels of horizontal display space, Instead of the increased iPhone of 480. The result is iSore.

Presumably, the problem is that UISearchDisplayController performs poorly in its willRotateToInterfaceOrientation: duration: method. Specifically, before setting the combineLandscapeBars property on its UISearchBar , No need to check if it is on the iPhone. The private API kludge in your code can work normally because it fixes the negligence in UISearchDisplayController. However, of course Apple will gradually reduce the anger of the ancients for you because of the use of undocumented APIs , So you can’t do it. Really, we are at the disposal of Apple.

If you are willing to give up the eyes and convenience of UISearchDisplayController, you can use UISearchBar without UISearchDisplayController and manage all aspects of the presentation yourself. Obviously, If Apple’s API engineers complete their work, this requires more code and is pointless, but it will at least solve the display error.

If you are Apple, you can use your own undocumented API, this is why Mail.app does not have this problem.

UPDATE

The bug report I submitted to Apple is #8344719.

p>

I have seen Apple’s example “TableSearch”. When you touch its range button, it will Appears below the search bar.
http://developer.apple.com/iphone/library/samplecode/TableSearch/Introduction/Intro.html

But when I make it myself, It looks good, but when I touch it and it looks ugly, the range button and the search bar are displayed in the same line, as shown below:
http://cl.ly/BN9

What should I do to make it like “TableSearch” in iPad?

I am doing everything in IB and trying to modify the search bar programmatically from the controller:

- (void)viewDidLoad {

[super viewDidLoad];
self.tableView.rowHeight = 88.0f;
self.tableView.contentOffset = CGPointMake(0, self.searchDisplayController.searchBar.frame.size.height) ;
self.searchDisplayController.searchResultsTableView.rowHeight = self.tableView.rowHeight;


//BELOW DID NOT WORK:
CGRect b = self.searchDisplayController.searchBar .bounds;
self.searchDisplayController.searchBar.bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, self.tableView.rowHeight);
b = self. searchDisplayController.searchBar.frame;
self.searchDisplayController.searchBar.frame = CGRectMake(b.origin.x, b.origin.y, b.size.width, self.tableView.rowHeight);
< br /> //BELOW WORKS PERFECT BUT IS A PRIVATE METHOD, HENCE I AM NOT SUPPOSED TO USE IT
//[self.searchDisplayController.searchBar setCombinesLandscapeBars:NO];

}

Thanks in advance.

I have also encountered this error, I have submitted a report to Apple and requested Provide technical help. I will tell you how it goes. At the same time, I will briefly introduce this bug.

On the iPhone, in order to preserve the precious vertical screen in landscape mode Space, UISearchDisplayController sets UISearchBar to combine its search bar and search field in a single horizontal layout. Since the horizontal size of the screen is increased (480 dots horizontally), the effect is very good. Unfortunately, it does not work very well on the iPad , In landscape mode, you do not need to change the UI first because you have enough vertical space. In the main view of UISplitViewController, you still only have 320 pixels of horizontal display space instead of the increased 480 of the iPhone. The result is iSore.

Presumably, the problem is that UISearchDisplayController does not perform well in its willRotateToInterfaceOrientation: duration: method. Specifically, before setting the combineLandscapeBars property on its UISearchBar, there is no need to check whether it is on the iPhone. In your code The private API kludge can work normally because it fixes the negligence in UISearchDisplayController. However, of course Apple will gradually reduce the anger of the ancients because of the use of undocumented APIs, so you can’t do it. Really, we are affected by Apple. Control.

If you are willing to give up the eyes and convenience of UISearchDisplayController, you can use UISearchBar without UISearchDisplayController and manage all aspects of the presentation yourself. Obviously, if Apple’s API engineers have completed their work, this needs more Too much code and meaningless, but it will at least solve the display error.

If you are Apple, you can use your own undocumented API, which is why Mail.app does not have this problem.

UPDATE

The bug report I submitted to Apple is #8344719.

Leave a Comment

Your email address will not be published.