How to implement pick button - ios

I'm creating UI for my application and i need to know how to implement pick button for IOS.
I have one row in my interface (height=44) for this purpose. So i think to create button and push segue to table with list of options.
When user taps button -> select option -> back to main view`, s/he must see selected option near the button (like table cell with details).
I don't know how to create custom button with 2 titles or something like this?

So what you do is subclass UITableViewCell and create a new cell with the button on the left and a UILabel for the select option. Then use that custom cell in your UITableView instead of the standard UiTableViewCell. When user taps button - take them to the options screen. Save their selection so that when you return to the main view, you can reload the UITableView with the selected option set.

Related

Can I choose only portion of a row in UITableView to be clickable(selectable) in Swift?

So I have a table in the accordion style. When a row is clicked, five radio buttons are displayed. Then, users should be able to click on those buttons. It successfully displays the buttons, but when the buttons are clicked, instead of highlighting the selected button, it shrinks the row itself. I think this is probably because I implemented each set of the label part and the option part as a single row, just in different UIViews. I believe clicking on the view that contains buttons is overridden by clicking on the row(label + options). Its really hard to explain, but I think a solution could be restricting selectrow action of the table to only certain portion of the row.
Is there a way I could achieve this? If I cannnot, is there other ways to implement the accordion table to be used as I described?
I am having a really hard time trying to explain this. If you have any questions, please let me know.
table
As per my understanding you van give a try to below steps:
Disable the row selection so that you can avoid row selection. Usecell.selectionStyle = .none
Secondly for your button in row set the IBAction in controller class and in Storyboard connect those actions to specific buttons.

Loading Data in sameTableViewController based on button press Swift

I'm working on a sample iOS app and want to load (in a tableViewController) certain data based on the button the user presses at the top of the view. For example, when the user loads the page it will by default load data from "myPosts" but on the top of the view there will be two buttons "My Posts", "Not My Posts". If they then select the "Not My Posts" button then the tableview cells will be reloaded with the data from "notMyPosts". Anybody know how to do this?
So, the best solution here is to use a Segmented Control. Basically, you will have a controller for each TableView and a controller for the SegmentedControl.
This tutorial and this question gives a basic idea on the segmentedControl and how to set the basic controller for it. You will basically have a Container View with a view for each tableView you want to display and show/hide it based on the selected segment on the SegmentedControl.
This is how your storyboard will look like:
Just use two different datasources for your table, depending on which button the user selects.
So, when the user taps on a button set a variable to keep track of which button they tapped, and then reload your tableview.

UITextView Data Selectors Without User Interaction Enabled

I have a UITableView of custom cells that contain a UITextView.
I want the UITextView to have data detectors (so that you can tap on URLs), however, I also want the user to be able to tap on the table view cell to select it. With the data dectors, I must have user interaction enabled, but to select the cell when tapping on the UITextView, I must have it disabled.
Is there any easy way to go about doing this? Thanks!
Add a UITableViewCellAccessory (checkmark, disclosure indicator or others) to your cells. Then use the method tableView: accessoryButtonTappedForRowWithIndexPath: in order to detect click on the accessory.

How to populate a "Favourite" section in a UITableView

I want to create a UITableView with 2 sections:
The first (upper) section lists entries from the second section that have been marked as "favourite".
*) The user shall be able to choose an entry, which results in the dismissal of the UITableView
*) Deselect an entry as favourite
The second (lower) section lists entries with a title and a subtitle.
The user shall be able to
a) choose an entry - which results in the dismissal of the UITableView
b) Select/Deselect an entry as favourite - which leaves the UITableView on screen, copying the selected entry into the "favourite" (first) section.
My questions:
Are there any best UI/UX practices on iOS to achieve this (IMHO rather standard) behaviour?
And/Or do I have to manually create a custom UITableViewCell with an UIImageView (for the "favourite" icon), and two labels (for title and subtitle), and attach a Tap gesture recognizer to the UIImageView?
I'd prefer not to create a separate "Edit" state for the table view, letting the user rearrange the order - all I want is either select an entry, or toggle favourite on/off.
Thanks
You can use the UITableViewCell accessoryView property to add your button / image view. You can use either a gesture or a target/action to be notified about selection.

How can I detect a right swipe on UITableCell and display a custom button instead of Delete button

I want to display a "Duplicate" button where the Delete button would usually appear if the user swipes from left to right on a UITableView cell. I understand I can add a gesture recogniser to the cell as per this example https://stackoverflow.com/a/6167841/2567126.
How do I create and place a button on the cell so that it appears in a similar manner to the Delete button to allow the user to confirm the action? The cells are just standard UITableViewCells with the default style.
You can change the title of delete button with delegate method - tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:.

Resources