I want to create UISearchbar with two input fields one for keyword and the other for location like Yelp application , how i can do something like this , please advice
I don't think you can have two search parameters in the same UISearchbar. You will have to create your search component for that, maybe a view with two UItextField and a Search Button and you can use UITextFieldDelegates to perform the various search operations.
Refer to Customizing Appearance of UISearchBar from Apple.
Related
I am a very basic SWIFT Xcode programmer. I make small apps.
For last 2 days, I am stuck at a very simple thing and I am sure with your guidance I can quickly make a decision.
I have a UIViewController class as well as an xib
In the layout I have 4 textfields
Now based on a user setting (in another frame user make a choice), I will either have to show 4 textfields ** OR ** 3 textfields and a UISwitch.
Long story short, if user select one option he should see UISwitch and 3 textfields or else 4 textfield. The labels's text also change.
To my limited knowledge, I will make another UIViewController, another XIB file and if user selection allows I will segue to the new UIViewController.
But all this looks so redundant. How do you smart people do this thing?
(Edit)
I use size classes in my layout as well as constraints in the visual editor for positioning of elements on the layout. If I change things programmatically, which is one option, how will I manage the layout ?
Please advise.
Show me the right path please.
When user select first option based on action show or hide the text field or switches, like when user select first option only show three text field and one UIswitch hide fourth text field.
And programatically change text field hint value and also set NSString Tag="first" so that when you want that value at the time of submit button you can apply if condition to tag and on that basis you can get your desired output on each selection.
I need to add a search bar to my project, which I call the server passing as parameters words entered into the search bar.
All the examples I have found look on a TableView that contains data on which search is made but this is not what I want.
I thought of doing with a TextField but would like to know first if I could do with a SearchBar.
ps: sorry for my english ;)
Here If you get all the data from the server using Web Services then here no meaning to use searchbar. you can do same thing with the textField also.
But if if you want it to look as search bar then you can use the photoshop designed UI. and validate text filed as search-bar.
I am trying to accomplish the following:
Read and Parse the text in a UITextField. Identify all the numbers in the UITextField and convert these into hyperlinks.
When these hyperlinks are clicked perform a custom action, which is to display a UIActionSheet and based on the selection assign the number (in the hyperlink) to another UITextField instance
For example if the UITextField has the text - "This is a sample test with number 123445 and more numbers 44555, 66777".
I should be able to parse the above text, detect all three numbers and add hyperlinks to them.
For the first part (parsing) I found out that there is a NSRegularExpression class that can be used to detect patterns in a text. But I could not find a way of adding hyperlinks to the matched numbers. I tried looking at Three20 documentation and could not figure out a way. Even tried the answer in this link - Just how to you use TTStyledTextLabel? but it only auto detects URLs and adds hyperlinks to them, I want to add hyperlinks to any custom text.
Can someone please help me with this. Please do not ask me to use WebView. I would really appreciate some code snippets. Thanks in advance. I am using xCode4.
If you don't need the text to be user-editable directly, you may use my OHAttributedLabel class to achieve this. (here on github)
This allows you to display any NSAttributedString and can also autodetect links, phone numbers and everything Apple's NSDataDetector class is able to detect. You can also add custom links to your label on any part of the text.
See the sample project included in my github repository for more details.
It is very customizable, both for link colors, underline style, action to perform when a link is tapped, which link types it should autodetect, and you can add any custom links and style you need on the text.
I'd like to use the text correction ui element in my own UIView.
Is this allowed & possible? If so, how can I use the element?
Clarification: I don't want to use it as a text correction feature.
I want to use it as UI elements to show multiple (dismissable) tags on a UIView to show & modify predicate settings.
You can use UIMenuController, which might be close to what you want (it's the thing that shows the Cut/Copy/Paste/Replace menu in text fields). See the CopyPasteTile and Touches sample code for details.
If you actually mean the thing that pops up with spelling completion suggestions, then no, you can't easily use it. You'll have to create custom buttons as you mentioned above. But, try downloading and running UIKit Artwork Extractor to help with getting UIKit artwork to match the look of your custom buttons.
Text correction? Do you meant the auto-complete / correct features you get when you type text on iOS? If so, you get that for free as part of UITextField or UITextView, so the answer would be yes. You can define exactly what you want corrected as part of the properties of those two classes.
I am creating a dictionary-style app that presents a tableview full of words, and when a word is selected, a UITextView is displayed that shows the definition of the word. What I would like to do is add a line that says "See also: synonym1, synonym2" where synonym1 and synonym2 are links that will take the user to the definition for the synonym that is touched.
What is the best way to add these dynamic links? Buttons? Somehow add a small UIWebView a UItable on the fly?
Thanks!
I would replace your UITextView with a UIWebView and use that contain your description text and your links. It's fairly trivial to generate HTML on the fly for something like that.
You could register a custom URL scheme for your app, or you could intercept links as they're clicked.
If your links are always grouped together there's no reason why you couldn't use a bunch of UIButtons inside a custom view, but then you'd have to handle layout and wrapping on your own. It seems a lot easier to do it in HTML.