Note that there are some explanatory texts on larger screens.

plurals
  1. POButton is supposed to change image after click, but (randomly) changes images of other buttons too
    primarykey
    data
    text
    <p>In my cellForRowAtIndex I initialize a button (it gets shown in every cell in the tableview): </p> <pre><code>UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button addTarget:self action:@selector(customActionPressed:) forControlEvents:UIControlEventTouchDown]; [button setTitle:@"" forState:UIControlStateNormal]; button.frame = CGRectMake(0.0f,cell.frame.size.height -15, 160.0f, 15.0f); UIImage *buttonImage = [UIImage imageNamed:@"Image1.png"]; button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [button.titleLabel setFont:[UIFont fontWithName:@"Arial" size:13.0]]; button.contentEdgeInsets = UIEdgeInsetsMake(1, 60, 0, 0); [button setBackgroundImage:buttonImage forState:UIControlStateNormal]; [cell addSubview:button]; button.autoresizingMask = UIViewAutoresizingFlexibleTopMargin; </code></pre> <p>It has a normal image and if the user clicks on the button, the image changes. Also I get the contents of the button.title from a XML. Therefore I tell it to get the right title from the web. This works fine, but sometimes (not all the time) and also randomly it changes the button from the next cell, or the cell three rows down. I don't know why and couldn't find anything while running with breakpoints/debugger.</p> <pre><code>-(void)customActionPressed :(id)sender { UITableViewCell *owningCell = (UITableViewCell*)[sender superview]; NSIndexPath *pathToCell = [self.tableView indexPathForCell:owningCell]; UIImage *buttonImage = [UIImage imageNamed:@"image2.png"]; [self doXMLParsing]; [sender setBackgroundImage:buttonImage forState:UIControlStateNormal]; NSString *TableText = [[NSString alloc] initWithFormat:@"%@", [[tabelle objectAtIndex:pathToCell.row] pressed1]]; [sender setTitle:TableText forState:UIControlStateNormal]; ((UIButton *)sender).enabled = NO; } </code></pre> <p>So maybe someone can see where I went wrong. If you need more code, just say so. </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.
    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