लिए एक समान लग रहे बनाए रखने के लिए आम तौर पर आप एक उपकरण पट्टी के अंदर एक खोज पट्टी डाल करने के लिए नहीं करना चाहती संघर्ष कर रहा हूँ, हालांकि, यह ऐसा लगता है कि आप कुछ ऐसा करना चाहते हैं जो मैंने किया था।
तो यहाँ मैं इसे कैसे किया, यह एक हैक बुलाया जा सकता है, लेकिन यह एक आकर्षण :)
पहले की तरह काम करता आप इसे इस प्रकार इंटरफ़ेस बिल्डर में स्थापित करने के लिए है:

ध्यान दें कि खोज टूलबार का बच्चा नहीं है, बल्कि यह ऊपर है।
खोज बार में "स्पष्ट रंग" पृष्ठभूमि और लचीला बाएं, दाएं और चौड़ाई ऑटोरेसाइजिंग मास्क होना चाहिए।
आपने टूलबार के नीचे काले पृष्ठभूमि के साथ 1-पिक्सेल लेबल रखा है, यानी। [x = 0, y = 44, चौड़ाई = 320 या फ्रेम चौड़ाई, ऊंचाई = 1], लचीला बाएं, दाएं और चौड़ाई ऑटोरेसाइजिंग मास्क। यह एक दृश्य पिक्सेल को छिपाने के लिए है, खोज डिस्प्ले नियंत्रक तालिका को दिखाता है राय। इसका अर्थ समझने के बिना इसे आज़माएं।
आप कोई टूल बार आइटम सेट अप करते हैं और उनके लिए आउटलेट रखना सुनिश्चित करते हैं, क्योंकि आपको उनकी आवश्यकता होगी।
और अब कोड के लिए ...
जब आप खोज शुरू:
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
// animate the search bar to the left ie. x=0
[UIView animateWithDuration:0.25f animations:^{
CGRect frame = controller.searchBar.frame;
frame.origin.x = 0;
controller.searchBar.frame = frame;
}];
// remove all toolbar items
[self.toolbar setItems:nil animated:YES];
}
जब आप खोज सिरे
- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller
{
// animate search bar back to its previous position and size
// in my case it was x=55, y=1
// and reduce its width by the amount moved, again 55px
[UIView animateWithDuration:0.25f
delay:0.0f
// the UIViewAnimationOptionLayoutSubviews is IMPORTANT,
// otherwise you get no animation
// but some kind of snap-back movement
options:UIViewAnimationOptionLayoutSubviews
animations:^{
CGRect frame = self.toolbar.frame;
frame.origin.y = 1;
frame.origin.x = 55;
frame.size.width -= 55;
controller.searchBar.frame = frame;
}
completion:^(BOOL finished){
// when finished, insert any tool bar items you had
[self.toolbar setItems:[NSArray arrayWithObject:self.currentLocationButton] animated:YES];
}];
}
इस मैं एक अच्छा एनीमेशन के साथ निम्नलिखित पाने के साथ
:)


तो .. आप UISearchBar को कस्टमाइज़ करना चाहते हैं? क्या यह सवाल है? –
मुझे लगता है कि मेरे पास दो प्रश्न हैं: 1. यदि मैं UISearchDisplayController को जोड़ रहा हूं तो क्या मुझे UIToolbar में UISearchBar एम्बेड नहीं करना चाहिए? 2. यदि UISearchDisplayController में UISearchBar का स्वरूप ठीक किया जा सकता है, तो यह सक्रिय होने पर यह कैसे किया जाता है? वर्तमान में इसे फिर से खींचा और पुनर्स्थापित किया गया है और UIToolbar में UISearchBar के रूप को नहीं बनाए रखता है – Rammeln