ButtonTappedForRowWithIndexPath not called

I have an application that works great on a simulator and on an iPhone OS 2.2.1 device. But I also have a device with iPhone OS 3.0 installed. And when I click the expand button, the accessoriesButtonTappedForRowWithIndexPath method is not called, however, the color of the expand button becomes darker.

Has anyone encountered such a problem?

How can I solve this problem?

+4
source share
2 answers

Now that OS 3.0 is officially out the door:

The problem is the UITableViewCell accessory property. Use the tableView: accessoryTypeForRowWithIndexPath: method to delegate if you are targeting both OS 2.x and OS 3.x.

+1
source

Unfortunately, "accessoryTypeForRowWithIndexPath" is deprecated.

The key to the different behavior (between the UITableViewCellAccessoryDisclosureIndicator and the UITableViewCellAccessoryDetailDisclosureButton) is that the INDICATOR of the expansion does not track, while the BUTTON of the expansion does the โ€œtrackingโ€.

What you need to do is to provide your own recognition of where the user is listening in the cell, and use it as part of additional code to call in

- (void)tableView:(UITableView*) tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath*) indexPath 

- this is what happens with the opening BUTTON.

You might want to use something like a UITapGestureRecognizer connected to an AccessoryView in your custom cell. Usually this is NIL, so you need to add a UIView to the cell via IB or programmatically - change its size and connect it to your cell object. Then you add the code to your custom cell function - (id)initWithStyle:(UITableViewCellStyle) style reuseIdentifier:(NSString*) reuseIdentifier .

The general idea is shown below.

  UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:myAccessoryView action:@selector(didTap:)]; tapGesture.delegate = (id <UIGestureRecognizerDelegate>)myTableViewControllerDelegate; [containerView addGestureRecognizer:tapGesture]; [tapGesture release]; 

The "didTap:" function then forwards your code, or simply does what you could do in another routine.

It is sad that three different accessories are handled differently. So, if you do not want your camera to have a blue and blue substance, it looks like you have to come up with additional code to make it work the way you would like.

One of the advantages of using AccessoryView in a custom cell is that you can put a UIImageView in a view and then put the image in a UIImageView, which means that you can use any image compared to a simple ">" expansion.

0
source

Source: https://habr.com/ru/post/1285847/


All Articles