How to add search bar in navigation bar for iphone? -


संभव डुप्लिकेट:

यह खोज बार प्रदर्शित करने के लिए कोड है, लेकिन मैं इसे नेविगेशन बार में रखना चाहता हूं

  sBar = [[UISearchBar alloc] initWithFrame: CGRectMake (0,10,320,30)]; SBar.delegate = self; [Self.view addSubview: एसबीआर]; //[self.navigationItem.rightBarButtonItem addSubview: एसबीआर]; //self.navigationItem.rightBarButtonItem=sBar;  

क्या कोई तरीका है?

सर्च बार को जोड़ें नेविगेशन बार में शीर्षक देखें इस कोड के उदाहरण में इसे अतिरिक्त शीर्षक के रूप में जोड़कर अतिरिक्त पैडिंग के लिए एक फिक्स भी शामिल है।

  UISearchBar * searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake (-5.0, 0.0, 320.0 , 44.0)]; SearchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth; UIView * searchBarView = [[UIView alloc] initWithFrame: CGRectMake (0.0, 0.0, 310.0, 44.0)]; SearchBarView.autoresizingMask = 0; SearchBar.delegate = self; [SearchBarView addSubview: searchBar]; Self.navigationItem.titleView = searchBarView;  

Comments

Popular posts from this blog

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -

session - security issue: php login/logout script + back button -

Eclipse and GWT -