Help with iphone button pressed
- by StealthRT
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?