How do I tell the difference between the user tapping my table view cell and the user tapping a subview contained within the cell? - iphone

One of my view controllers contains a UITableView with custom UITableViewCell's. My custom UITableView cell contains a UIImageView subview that represents a tappable icon. When the user taps anywhere on the custom cell, except the icon subview, I want my didSelectRowAtIndexPath method to be called like normal. But when my icon subview gets tapped, I want a different method to get called, but I can't figure out how to do this. Do I have capture the touch position in the touchesDidBegin method and manually check if the user tapped the icon? That just feels so hacky. Other, cleaner ideas?
Thanks so much for your wisdom!

Simply add a tapGestureRecognizer to the UIImageView in your cell

Related

Drag UITableView or all TableViewCells to display a label

I'd like to create make a table view go to left when we swipe with a pan gesture. The goal is to display a label a the right of the table view like Instagram or iMessage for instance. Does anyone have a tip for creating this?
The result I would like to get.
https://i.stack.imgur.com/kDdSa.jpg
As a rough sketch, you may place a subview containing a timestamp inside your cell, below or to the side of the main subviews that display the content. You also will need to write a method that, depending on the pan progression, will show/hide this timestamp. Then you add a pan gesture recognizer to the table view itself, and, once panning, in your handler method you can call this disclosure method on the visible cells.

View with uitableview, tabbar and more objects

I'm developing an app and I need a view with these elements:
- UITableView
- UITextField and UIButton
- TabBar
As you can guess, I am developing a chat, but when I put the elements in the .xib, I can't show de layer: UITextField and UIButton. If I put them without a view, they dont appear.
If I put a view under the table, and in that view I put the text and the button I get this error: http://pastebin.com/CKfxijz9 (I put the error there because it's to long)
Thanks in advance
There are some ways of dealing with that, depending on how it should behave. Some of them are:
Provide a table footer or header view that holds the button and
the text field.
Nest the table view into another view. The table
view and the view containing the button and text fielt are on the
same level within the view hierarchy. They are rather siblings than
sub- and superview to each other.
Use a UISlider instead of a table. (However, I personally would use the table.)
Here's an approach I've used in the past (not sure if it's best practice, but it works).
Add your button and textfield to a new view (let's call it, bottomView)
Add bottomView to the superview of your tableview
Set the frame of your bottom view so that it fits to the bottom of the screen (this will make it so your tableview will scroll, but keep your bottomView always attached to the bottom of your mainview)

Add selector to button on UIScrollView views added dynamically

I have an UIScrollView with n views added dynamically from metadata stored by archiving. I have a PressGesture to make wobble animation (like iOS deleting apps way) and i want to add a button to every subview on the ScrollView for deleting it from the ScrollView and from files.
My problem is for adding the target to the buttons. When they are pressed, the selector (on the UIViewController parent of the UIScrollView) are not called.
How can I get this done? Any other approach is suggested?
Thanks in advance.
When you animate the view it stops responding to user input. And if your button is located inside animated view, it will definitely not call the selector.
The solution would be to wrap your wobbling view into a transparent superview and then place Delete button inside that superview. If you need your button to be also "wobbling" then you need to put an image that represents button inside your wobbling view. And inside wrapper put a transparent Custom button, that will in fact react on user tap.

Allow input in a UITableViewCell

So I have a UITableView (its in a UIPopOverController if that matters), and I want the user to be able to edit the content of the tableView. I added a UINaviagationController, the tableView also has a title and an edit button. Essentially what I'm asking is, when the user taps the edit button, how can I add like UITextViews to some of the tableViews and in one of the cells, a UISegmentControl and a UITextView.
Thanks in advance
just add them as subviews of the cell, set correct frame to make subviews inside the cell

removeFromSuperview only removes view from last cell

I have a UITableView set up with a custom delete button which consists of a UIButton (btnDel) added as a subview to the UITableView's cells. The delete button is added as a subview when my edit button is pressed. This works well but when I try to remove the subview using:
[btnDel removeFromSuperview];
It only removes the button from the last cell and the other cells still retain the now removed button. I've tried this in many different ways and still can't figure it out. I've tried using functions such as turning the opacity of the button to 0 or setting Hidden to YES, but like the removeFromSuperview, it only effects the button in the last cell with the others staying the same.
Any help is greatly appreciated and if anymore of my code is needed let me know.
If you don't keep references you can't tell which button belongs to which cell.
You might want to subclass UITableViewCell so that your cells have a property which points to the button (assign the button to the property right after instantiating the button). You could then use this property to access (enable, disable...) the buttons later on.