Showing last used text in a UITextField/UISearchBar - objective-c

I am trying to implement a search bar, and I am going to need to be able to show the last 10 searches that were entered when the user starts typing.
My background is non standard (a big background texture basically), and I can't find a way to make the search bar fit in the image without looking too funky.
So.
Is there a way to use a UISearchBar/UITextField to show last used searches? Or rather,
is it possible to take the background of the UISearchBar out (i.e. make it completely go away, leaving only the rounded rectangle of the search bar)?
Thanks!

For the first question:
Is there a way to use a UISearchBar/UITextField to show last used searches?
I dont understand what you want to do here..
For your second question..
UISearchBar *searchBar = [[UISearchBar alloc]init];
[searchBar setBackgroundImage:[[UIImage alloc] init]];//removes the color gray background
Hmm.. i dont think there is a way to delete/remove it completely though.. hmm.. maybe a customized UITextField with UISearchBar behaviour will achieve that..

Related

Custom TabBarItem menu IOS 7

I'm trying to make an UITabBarController like this:
No matter the device width (whether it is rotated or not) the buttons should not be stretched and the leftover space should be on the right side.
My questions:
Is this possible with the UITabBarController?
For the whitelines inbetween the buttons I am planning to use an unclickable UITabBarItem with an image. Is this the best way to do this?
With this tutorial that I followed I am getting this result:
2 problems here ^, whilst my background.png is 320x49, the selected image (68x49) has padding. This should not happen, both pictures have the same height?
The second problem is that the button/image has trailing space, and I want it sticked to the left side, as in my first screenshot. How would I accomplish this?
I don't expect anyone to post code, just merely a push in the right direction as I'm totally lost on this.
Check this library, you can customize the UI in interface builder with consstraints and get what you want.

Programmatically make color filled UIBarButtonItem

I have a UIBarButtonItem with the UIBarButtonSystemItemSearch type. I can programmatically change the tint color, like so:
searchButton.tintColor = [UIColor purpleColor];
However, what I'm trying to do is figure out a way to programmatically "fill" the button (i.e. the magnifying glass) with a given color. More generally, I'm trying to use a change in the icon to indicate that the search functionality is active.
I really like the built in search icon, but the lack of an obvious fill functionality is annoying. Is there any way to do something like this without creating an entirely custom button/icon? If not, what's the easiest way to utilize the existing search icon to create a custom button that does have the ability to be filled?
First off I would suggest simply using the tintColor to show your selected/unselected states without trying to mess with the shape itself since it is much easier and will convey what you're trying to do. Keep in mind that in this specific case, the magnifying glass may not even look right if it is filled in, that shape is very specific and people are used to seeing empty space in the circle.
If you want to continue on that route though, no you cannot easily change the built-in search icon. Your options are 1. programmatically take a snapshot of such an icon on the screen and try to manipulate that using CoreGraphics (not a great solution) or the better solution 2. which is just to get/make your own image and then you don't have to do any of it programmatically.

Add UIView to UITabBarItem

I would like to add a little red dot to a UITabBarItem in my TabBarController to indicate that a certain condition is triggered (in this case the content is filtered), much like Mail little number in Dock indicating how many unread mails you have.
Seems that this cannot be done looking at the Docs. So maybe there is another approach that can use to get this done.
Since the TabBar is always locked at the bottom of the screen I just can overlay another view on top but I am willing to know if there is a smarter way.
Use the badgeValue property of UITabBarItem. Read about it here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarItem_Class/Reference/Reference.html#//apple_ref/occ/instp/UITabBarItem/badgeValue

programmatically implement UIScrollView in a UIAlertView

I would like to programmatically Add a UIScrollView in a UIAlertView.
I found a way to do that but I was not successful in adding text to this UIScrollView (using the same code as in here: https://www.youtube.com/watch?v=4SG0CAAl5u0).
is there an alternative to do that? the text I have is very long and I need people to be able to scroll but without being able to edit it.
I know that the Apple user interface guideline does not recommend long text in alerts (although detecting WiFi networks does that) but I have no choice but doing it
If you add a large text in UIAlertView it automatically becomes scrollable.
You don't have to do any thing to make it scrollable.
Here is a control on github that has a tabelView inside it. If you need to customize beyond what Inder suggests, you might want to look at the code and replace the tableView with a scrollView.
Also, there are other controls at cocoacontrols.com that might help you directly or give you some ideas.

Editable text inside UISegmentedController

I want to have a UISegmentedController but the user can choose the segment and change the text inside. Is there any way to do that?
Thanks.
EDIT: This is what I would like to do. I have users which choose an option using UISegmentedControl. Under settings, I would like to give them the opportunity to modify what the texts in the UISegmentedControl is. I can use a UITextField and a button which triggers the change but I didn't like that solution. I considered putting a UISegmentedControl image with UITextField inside each segment but that does not seem like an elegant solution. Besides, I have no idea what the font is being used in UISegmentedControl. If I am not mistaken, by default, you can only fit a maximum of 12/13 chars or else it can break. iOS 5 SDK has some more methods to customize so it may be possible.
I coded a solution which involves a preview of what the UISegmentedControl will look like, 2 textfields to replace the texts inside each segment and a button which saves the value. I scraped it because I did not like the implementation and I just didn't like the execution too. I wanted the users to feel like they are using the UISegmentedControl and able to edit the texts inside it, up to a max of 12/13 chars.
Thanks.
You can always dynamically change the values of the segmented controller in code. Would it be acceptable to have the user click the button, at which point you could pop up a form for the user to fill in with the new value, and then call this method on the segmented control:
- (void)setTitle:(NSString *)title forSegmentAtIndex:(NSUInteger)segment