Hey!
I have stumbled upon a problem when adding a button to my table view cell.
Let me explain after i have added the code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
RadioCustomCell * cell = (RadioCustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[RadioCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
[cell setChannelImage:[UIImage imageNamed:@"p4.png"]];
UILabel *nowTitle = [UILabel alloc];
nowTitle.text = @"In My Heart";
[cell setNowTitle:nowTitle];
UILabel *nowArtist = [UILabel alloc];
nowArtist.text = @"Moby";
[cell setNowArtist:nowArtist];
UILabel *nextTitle = [UILabel alloc];
nextTitle.text = @"Only Girl (In The World)";
[cell setNextTitle:nextTitle];
UILabel *nextArtist = [UILabel alloc];
nextArtist.text = @"Rihanna";
[cell setNextArtist:nextArtist];
// My button right here
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(6 ,31, 110, 20);
[button setImage:[UIImage imageNamed:@"radionorge.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(touched:) forControlEvents:UIControlEventTouchUpInside];
[cell.backView addSubview:button];
}
return cell;
}
And the "touched"-function for the action for the button.
-(void)touched:(id)Sender {
// Here i want to get the UILabels for each cell. Such as nowArtist.
}
You see, i want to get the UILabel-texts for each cell at the touched-funtion. I know that you must use the Sender as a pointer in some sort of way, but i don't know how.
Please help.