uisearchbar

Unable to change UISearchBar cancel button title color after changing it's text.

微笑、不失礼 提交于 2019-12-10 19:06:26
问题 I'm using this code to change UISearchBar cancel button title: -(void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller{ self.searchDisplayController.searchBar.showsCancelButton = YES; UIView* view=_otsinguRiba.subviews[0]; for (UIView *subView in view.subviews) { if ([subView isKindOfClass:[UIButton class]]) { UIButton *cancelButton = (UIButton*)subView; if (cancelButton) { [cancelButton setTitle:@"Test") forState:UIControlStateNormal]; [cancelButton

Loaded the nib but didn't get a UITableView

懵懂的女人 提交于 2019-12-10 18:04:10
问题 I have been following this tutorial on YouTube (part 1 and part 2). I have completed both videos and have hooked up the view controller with the parent view controller using this code: - (IBAction)searchButtonClicked:(id)sender { NSLog(@"It works."); SearchViewController *searchViewControl = [self.storyboard instantiateViewControllerWithIdentifier:@"SearchControllerNav"]; [self presentViewController:searchViewControl animated:YES completion:nil]; } This code indeed works since this is the

UISearchController searchBar disappears on first click

流过昼夜 提交于 2019-12-10 16:57:29
问题 I have implemented a UISearchController in a TableView, pushed by a Navigation Controller. First my problem was that whenever I click on the SearchBar, it disappears. It works when I enter some text, but it stays completely blank. Then I managed to semi solve the issue using this code: - (void)searchForText:(NSString*)searchText { [self.view addSubview:villeSearchController.searchBar]; } Which semi-works because now, when I click on the search bar, it blanks out, but if I enter one character,

Custom UITableViewCell causing UISearchBar to crash

一个人想着一个人 提交于 2019-12-10 15:13:23
问题 I have a tableView with a UISearchBar set up. Every time the user starts typing in the search bar the app crashes. I discovered that the problem is that I'm using a custom tableViewCell (when I tried running the app with the default tableViewCell it didn't crash and worked fine.). Any ideas on how to fix this? Thanks. Here's my code: import UIKit import CoreData class KeepTableViewController: UITableViewController, UISearchBarDelegate{ @IBOutlet weak var searchBar: UISearchBar! var

How to change color of Search Bar?

自闭症网瘾萝莉.ら 提交于 2019-12-10 14:14:25
问题 I've implemented a Search Bar and I want to change color of Search Bar. How can I do that? I've tried with: self.mySearchBar.backgroundColor = [UIColor redColor]; but with no success. UPDATE (Solved): I had to remove the default background color before I defined background color with the following code. for (UIView *subview in mySearchBar.subviews) { if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) { [subview removeFromSuperview]; break; } } ... so code would be next:

iOS: How to replace Search Bar background shine/glow with one color

吃可爱长大的小学妹 提交于 2019-12-10 13:50:10
问题 How do I remove the shine/glow (gradient) from the background of a Search Bar. I would like to replace it with just one color. From this: To something like this 回答1: Use searchbar.backgroundImage = //your image here and you can use a nifty category that I created for uiimage that will generate an image based on a color https://github.com/Hackmodford/HMUIImage-imageWithColor So all together it will look like this searchBar.backgroundImage = [UIImage imageWithColor:[UIColor blueColor]]; That

UISearchBar Not appearing

心不动则不痛 提交于 2019-12-10 13:26:10
问题 I have view controller, into the view i have put a table view, and a search bar into the table's header... the search bar is not showing up, just the empty table view. Do i need to do something additional? I'm pretty sure its to do with the view outlet of the UIViewController, set to View ... Thanks 回答1: For anyone else who may be landing on this question, I had a very similar situation where a UITableViewController with a UISearchBar added to it wasn't displaying. If you find yourself in

UISearchBar jumps if pushed controller hides the tab bar

醉酒当歌 提交于 2019-12-10 13:09:21
问题 My UI structure is as follow: UITabBarController ( TBC ) -> UINavigationController ( NC ) -> UITableViewController ( TVC ) (for the simplicity of the example lets say the TBC has only one controller on its viewControllers array - the NC ) My TVC has UISearchBar as its table header, and when the TVC appear I hide the search bar beneath the NC navigation bar by settings the table view content offset. When user tap a cell in the TVC another view controller is pushed ( VC ) and hides the tab bar

UISearchBar animation hiding button

一个人想着一个人 提交于 2019-12-10 13:08:25
问题 I currently have a UISearchBar (attached to a UISearchDisplayController), but I reduced the width of the search bar so I could display a custom button to its right when the search bar is not selected. The button is used to access other views. However, when I select the search bar and then press cancel (or even perform a search) and return to the normal view, where the search bar should be displayed with my custom button, the search bar animates and takes up all the room for the button and the

How can I change a UITextField position in UISearchBar?

﹥>﹥吖頭↗ 提交于 2019-12-10 12:58:26
问题 Is there a way to reposition UITextField inside UISearchBar? I'd like to move UITextField inside UISearchBar up a little bit. 回答1: The UITextField approach is not working anymore, probably due to a restyling of the UISearchBar object. UISearchBar resizes its UITextField when it is presented on screen, this invalidates all manipulations on the UITextField. However, I discovered that UISearchBar responds to the setContentInset: method (tested on iOS 5.0.1). It adjusts the inset distance from