Help with iphone button pressed

Posted by StealthRT on Stack Overflow See other posts from Stack Overflow or by StealthRT
Published on 2010-03-23T21:33:27Z Indexed on 2010/03/23 21:43 UTC
Read the original article Hit count: 447

I am trying to see which button was clicked on so I can preform the correct logic.

This is the code for the buttons:

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(270, 423, 60, 60)];
[button addTarget:self action:@selector(buttonPressedAction:) 
    forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundImage:[[UIImage imageNamed:@"refreshicon.png"] 
    stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] 
    forState:UIControlStateNormal];

UIButton *button2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 423, 60, 60)];
[button2 addTarget:self action:@selector(buttonPressedAction:) 
    forControlEvents:UIControlEventTouchUpInside];
[button2 setBackgroundImage:[[UIImage imageNamed:@"login.png"] 
    stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] 
    forState:UIControlStateNormal];

[self.navigationController.view addSubview:button];
[self.navigationController.view addSubview:button2];

And this is how I call the buttonPressedAction:

- (void)buttonPressedAction:(id)sender
{
 NSLog(@"%@", [sender value]);

 isRefreshing = TRUE;
 [self loadTheXML];
 [self.tableView reloadData];
}

But when I use NSLog to see what the sender value is, it crashes.

Any advice for what's happening and how to correct it?

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.0

Related posts about cocoa-touch