Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView custom accessory button image disappears when tapped
    primarykey
    data
    text
    <p>I have a UITableView with a custom accessory button created like this:</p> <p>in <code>cellForRowAtIndexPath</code> method i do the following:</p> <pre><code> ... UIButton *myAccessoryButton =[[[UIButton alloc] init] autorelease]; myAccessoryButton =[self makeAccessoryButton: @"arrow2.png"]; [cell setAccessoryView:myAccessoryButton]; return cell; </code></pre> <p>and the function <code>makeAccessoryButton</code> is defined as follows:</p> <pre><code>- (UIButton *) makeAccessoryButton: (NSString *) imageName { UIButton *myAccessoryButton = [[UIButton buttonWithType:UIButtonTypeCustom] autorelease]; CGRect frame = CGRectMake(0, 0, 24, 24); myAccessoryButton.frame = frame; [myAccessoryButton setBackgroundColor:[UIColor clearColor]]; [myAccessoryButton setImage:[UIImage imageNamed:imageName] forState: UIControlStateNormal]; [myAccessoryButton addTarget: self action: @selector(accessoryButtonTapped:withEvent:) forControlEvents: UIControlEventTouchUpInside]; //myAccessoryButton.userInteractionEnabled = YES; return ( myAccessoryButton ); } </code></pre> <p>and the function is defined as follows:</p> <pre><code> - (void) accessoryButtonTapped: (UIControl *) button withEvent: (UIEvent *) event { NSLog(@"testing ..."); } </code></pre> <p>Now the problem is: When I tap on this button, its image will disappear only when the row is highlighted, I tried both states <code>UIControlStateNormal</code> and <code>UIControlStateHighlighted</code> for that button but the problem still exists, as I mentioned. If I tap that button if the table view row is not selected (or highlighted) there will not be any problem with the button image (it will not disappear). How can I fix this problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload