I am developing an iPhone application where i need to show UIButtons with back images horizontally(each row two buttons with back images) with scrollbar provision in a View. I have a tabbar application created. Please refer the attached sample image. How can i develop such screen? Do i need create tableview with just ONE row, where i can add UIButtons with back images horizontally (or) How can i achieve it easily? Is there a sample program available? Note: When clicking on button, i also need to know which button is clicked. I have actions for all buttons..
Please help!
UPDATED:
I'm able to achieve the buttons with images horizontally (in two button in a row). My problem is, how can i tag it properly, so that i can action it properly.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell=[[UITableViewCell alloc]init];
static NSString *CellIdentifier1 = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
// if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier1] autorelease];
//}
tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
cell.backgroundColor = [UIColor clearColor];
UIButton *btn1 = [[UIButton alloc] initWithFrame:CGRectMake(11.0, 6.0, 80.0, 65.0)];
//UIImageView *imageView = [UIImage imageNamed:@"avatar.png"];
btn1.enabled = YES;
// btn1.tag = ?????; // HOW can it tag it properly.
[btn1 setBackgroundImage:[UIImage imageNamed:@"image1.png"] forState:UIControlStateNormal];
[btn1 addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:btn1];
UIButton *btn2 = [[UIButton alloc] initWithFrame:CGRectMake(180.0, 6.0, 80.0, 65.0)];
[btn2 addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
// btn2.tag = ?????; // HOW can it tag it properly as it is in horizontal position.
[btn2 setImage:[UIImage imageNamed:@"image2.png"] forState:UIControlStateNormal];
[cell.contentView addSubview:btn2];
}
-(IBAction) buttonPressed: (id) sender
{
UIButton *button = (UIButton *)sender;
NSLog(@"Btn Tag: %d", [sender tag]);
}