Text input pop-up for adding to tableview - ios

I have a table view list and an add button at the top right. The user would press the button and a text field would pop up for a user to enter a string to be the label of the new item. Nothing new or special, what you'd expect from a "new playlist" type situation.
I am looking to have the small text field input that the user would type into. Most examples have the app move to a new view controller with a text field. I simply want a little box to overlay the current view that accepts a string. I cannot find/remember the name of the text box so I cannot find examples or code.

I think you are searching for something like
https://github.com/bmancini55/iOSExamples-DockedKeyboardView
Where your UITextField would be attached on the keyboard's accessory view.
OR
http://nshipster.com/uialertcontroller/
Where you use an UIALertController with an input field. I think the second one will resolve your problem more than the first one, because you are asking for a pop-up solution.
Hope it helps

Related

Hide or Show elements after picker view elected or text field input

I have a form and many UIPickerView and UITextField but I want to:
Hide some Picker View avec Text Field (here I'm going to use the attribute hidden) but I don't want to have a blank space, so how to do this?
When I select an item in the Picker View or input something in a Text Field I want to show the hidden item.
How to do this without having blank space?
Here is one approach :
One approach is to create the pickerview and textField in code and add it to the view.
This approach has the following advantages :
Since you are creating the textField only when you need it. Your
will not be using up valuable memory.
You will not have any white space.

Use link words in a text in UITextView [Objective-C, Xcode]

I`m starting in Objective-c this Year and I found nothing that could help me in the logic of how elaborate it:
Look!
I have a UITableView with a list of drugs. When I click on any medication, I'm taken to a DetailViewController that displays the text information about this drug. In this text, I want every time a drug name appear, it appears as if it were a “link”. So when the user clicks, it will be taken to other remedy detailviewcontroller without need to go back to the list of remedies! What is the better way to implement this?
I thought about passing an array with all drugs for DetailTableView controller via Segue, and then conduct a search for any of the remedies present in the text, but i don't know how to turn that word into a link, or set a function to become part of the text (the drug name) clickable
Just to make it clear, let's assume that we are reading the details of the text on the drug called Amoxicillin:
“Amoxicillin drug works better than erythromycin”
What I want is that the name Erythromycin become some kind of link, so when the user clicks on it, is brought to the screen details about erythromycin. Do you guys understand what i mean?
P.S.: I saw that the UITextView has an option called "Links" in attribute inspector, but i have no idea how to use it or if this is for what i want
Thank you all again!!
Use UITextView And select these attribute.

How to select a UITextField without showing UIKeyboard

I am wondering if there is a way to use a UITextField programatically (i.e. use buttons as inputs) so that you can select a UITextField but not show the UIKeyboard, then when you select a UIButton it would assign a string value to the currently selected UITextField.
I don't really know where to start.
I think you can visually change the appearance of the text field (for example add a blue border), let the user feel it’s “selected”. Then you just modify textfield.text when user presses button.
Or alternately, you can create a customized keyboard. There are many similar questions.
It seems that you don't really need a text field (e.g., edit/select text, etc.), but a "button that stays highlighted" instead. Then, you can programmatically change the button's title label to the specified string when the user taps the 'proper' buttons.

Add a Text Link to a TextView

Is it possible to add a text link into a TextView? I want the link to perhaps behave like a button, where I can assign an action to it.
EDIT: When I say assign an action, I mean actually giving it something in the code. I'm wondering if it's possible to dynamically add a "button" into text that I can assign a coded action to.
Live scenario
Think of something like a dictionary app. Maybe the definition of one word uses another word that you might not know the definition of, so being able to click on that word to instantly search it rather than having to type it in would be a nice user friendly feature. It seems rather unlikely, though, I guess.
I would recommend using NIAttributedLabel from Nimbus, an open source iOS library. You can specify text ranges that are links, and you get delegate messages sent when a user taps on it.
Main Nimbus site: http://nimbuskit.info/
NIAttributedLabel docs: http://docs.nimbuskit.info/interface_n_i_attributed_label.html
in the inspector, go to the Text View Attributes tab then make sure "Detect Links" is checked.
Yes you can. Add the URL into the text view, then open up the Attributes Inspector. You will see an option in there to detect links.
I know of a way, but its a LOT of work. First, you have an NSAttributedString that you have the text view display. Second, attribute the range of text you want to be the button. Third, assign a tap gesture recognizer to the text view and in the method called by the recognizer, you'll use core text to determine if the tap happened over the range of text that represents the buttons.
Heres how youll use core text: create a framesetter with the attributed string. Create a frame from the framsetter with the shape of a square that is the frame of the text view, inset by the padding of the text view. The frame will allow you to get the y origins of every line in the text view and and once you know what line the tap happened on, you can use the line to then figure out exactly what character was tapped on that line by giving it an x offset. Once you know character index on the line, you can add it to the beginning of the range of the line and get the index of the character within the whole string. Then you can check if its within the range of the text that is your button. If it is, you can then call a method to simulate a target action type behavior.
Ive explained the process of how to accomplish this and specified what kinds of core text objects youll need, ill let you look up the specific api details:
https://developer.apple.com/library/mac/documentation/Carbon/Reference/CoreText_Framework_Ref/_index.html#//apple_ref/doc/uid/TP40005304
You can also use my objc core text wrapper:
https://github.com/mysterioustrousers/MYSCoreText
What about CoreText? It Can draw many kinds of Text .

UITextView at the bottom of the view

As a new MonoToucher, I have a question which I'm struggling for a while now:
In some cases in my app I need to display a UITextView with a button to its right, at the bottom of the screen.
Basically, I would like to manage some kind of discussion feed in which when the user navigate to a specific discussion he gets the related posts as a list and have a multi-line text input at the bottom of the list with a 'Post' button to the right.
Touching that textView should show the keyboard for input, and the height of the textView should be related to the data entered.
This is the same behavior as we have when we want to write a new Text Message in iPhone, or a post in Facebook.
Another requirement is, that when the user scrolls the posts list, that input (with the button) should not move.
I tried creating a UIToolBar with UITextView and a UIButton, but I can't make it work as expected.
Check out the BubbleCell sample, it does exactly what you want in C#:
https://github.com/xamarin/monotouch-samples/tree/master/BubbleCell

Resources