UITextView Data Selectors Without User Interaction Enabled - ios

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.

Related

Is it possible to change attribute of individual UITableViewCell?

Is it possible to make changes to a particular UITableViewCell? For example, change the text in one cell of a table view with a button click?
It's possible, but you should not do that.
As you said in your comment, you can ask the table view for a cell and then make changes to that cell, but don't do that.
You should do what HHumorous said, and change your data model, then tell the table view to reload the affected cell.
If you simply change the appearance of the cell, then when the user scrolls that cell off-screen and then back on-screen the changes will be lost.

How to disable the selection on UITableViewCell's accessory view only?

My UITableViewCell has an accessory view of UIButton on the right edge of the cell. However, the button might not be available to an user and thus I shall disable it via self.myButton.enabled = false.
While this makes the cell selection work as usual however, now the selection also reacts to the tap on the button. In other words, while the button is disabled and the user still taps on the button, the tap is now responding to the didSelectRowAtIndexPath: method.
This is not what I want, since it might confuse my users at times. So I want to implement it as follows:
When the button is available, tapping the cell and tapping the button execute different methods respectively (which I implemented and worked).
When the button is unavailable, tapping the cell works only on the part of where the button is not located.
Is it possible to set the functionality here?

How to implement pick button

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.

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.

UIPickerView in UITableViewCell - how to select values instead of scrolling TableView?

I've got a custom UITableViewCell that has a label and a UIPickerView. Display works fine, but when I want to select a value in the Picker, the TableView scrolls. What can I do so that the gestures in the cell go to the Picker instead of the whole TableView?
The only solution I could come up with was to set the whole TableView to scrollEnabled = NO. This works for the Picker, but now I can't get to the cells under the custom cell. Control has to be more fine-grained.
If you can get hold of the UIGestureRecognizer for each of the two gestures, and tell one it needs to wait for the other to fail. With one in every cell, that becomes over-wieldy.
Perhaps you should add a control or have the accessory view "bring up" the picker, and then dismiss it when done.

Resources