Implementing a tableview with multiple labels inside a cell - iphone

The tableview I am implementing is a kind of phonebook, where I have an entry(name) and below that I am displaying his/her phone numbers. These data make my cell.
An entry(name) can have multiple phone numbers(each phone number displayed in different lines). Against each phone number(in the same line) I have an option to set some status message. How can I implement this.
The way I have gone forward is:
I have created a 2 labels inside a cell. One for displaying the name and the other for displaying the numbers. These numbers are displayed in a multiline way. The problem I am facing is, adding the status message against each phone number(in the same row of each number). For that I may have to add the status as text in between the phone numbers(displayed in a multiline way) in the same label or I have to add another label inside this label. I am a bit confused regarding, how to go about this. Need help.

For multiple UILable in a cell, you can use custom cell.
What you are trying to implement is something like this or this. check it out.

Personnaly, I would add the "To" view as a subview of your UILabel and then set the toView.frame.origin.y to index * label.font.lineHeight.

Related

Should I make separate UIViewController just because a single row is different in layout

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.

how to add custom label view to uitextview?

I am developing one message application in ios for iPhone .
i have one textview in which i have to write name of persons and on input space in uitextview i have to show the previously entered content in different text with different background .let me explain with image!
can anyone help me how can i achieve this kind of thing in my text view with CROSS MARK and on click of Cross Mark I want to delete that bubble?
so when user inputs the space after write some string in textview then it will convert with following view in green background with cross button..
You want to use some type of token field. Search github. Something like this.

How to create a UITextField to enter multiple email addresses?

I have a UITextField and i want it be able to enter multiple email addresses. I want the functionality as line in MailComposer.
what I actually want is when user clicks a button i want to show address picker to select emails
Is there any predefined pickerView for that?
How can I do that?
One way might be to define a UITextField that is transparent on top of a UIView that can have other views as subviews. When you start typing an address you get textField:shouldChangeCharactersInRange:replacementString: in the UITextFieldDelegate. If the partial string matches then you can create a new UIView for each matching address and dynamically present them as options to be clicked/tapped to accept. You would probably use resizableImageWithCapInsets to create the bubble that the name sits on to allow for variable lengths. This list might change with every character.
If a choice is accepted then you would move the UIView containing the accepted address into the right position in the address line, to the left if there are no previous addresses, or after the last one if there are. Any other addresses shown would be dismissed at that time. Animation might look nice here. Then the frame of the UITextField would be altered so that text entry would take place after the UIView showing accepted addresses. It all looks like a UITextField, but it's not.
Other things to do would be to add a X button to each address allowing them to be removed. You could even parse the text as it is entered, if you have a good email address parser, turning text into bubbles and moving them up to the left with accepted addresses.

Adding a sectioned tableview - Beginner

I need to have a sectioned tableview like the following. I need a section to look like shown in the following image.
Home on one side, then on the other column Street, City, state, zipcode. And also Country and state should be on another row.
If someone could show me some sample code or a tutorial to start on this
note : you get the following UI when you are trying to add an address to a contact using your iPhone and sorry i don't have any code, i am clueless where to start.
Get creative. Sometimes something looks like a tableViewCell but it actually isn't one ;-)
Just a bunch of UIViews with lightGray backgroundColor and a width or height of 1. And those are arranged in cells that have different heights.

use tableview as uitextview

i want to develop a application like notepad app of iphone or ipod. i try my level best to design a uitextveiw like a paper with lines but it has a lot of problems like background image does not scroll with scroll of uitextview. and does not reapeat itself when text increases the background image.
its seems to me that the notepad app use a table view for taking input from user how i donot know.
so anyone who can tell me how to design a view like notepad app.
use a tableview and then place text field in each row such that if the text field limit reach the maximum length the next row text field become first responder. and when user click save then read data from all text field and then save it where u want.
but the only problem that i am facing is when the user past some data then i am unable to show that data in next text field if the past data is larger than the maximum length of a text field.
hope this help others.