Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7042007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:06:57+00:00 2026-05-28T02:06:57+00:00

I want to implement UITableView Where I want to have 3 buttons in each

  • 0

I want to implement UITableView Where I want to have 3 buttons in each UITableViewCell, I want to assign Tittles to each buttons Dynamically, if am having all titles in ‘title_array
‘ say then how can I get the index to an array for giving tittles to each buttons in each UITableViewCell ?

here is my code ,
which is not working,

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

   // printf("\ncellForRowAtIndexPath\n");
    //static NSString *CellIdentifier = @"Cell";

    NSString *CellIdentifier = [NSString stringWithFormat:@"identifier_%d", indexPath.row];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


    //if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];

        //cell.textLabel.text=@"Golbal VC";
    int x=50;

    if (indexPath.row == 0) {
        sample = 0;
    }else{
        if (sample == [titles_array count]-1);
        else sample += 2;
    }


    for(int i =0; i <2 ; i++){


        UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
        [btn setFrame:CGRectMake(x,50,300, 300)];
        [btn setBackgroundImage:[UIImage imageNamed:@"Canada.gif"] forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside]; 
        [cell.contentView addSubview:btn];


        UILabel *tit_lbl=[[UILabel alloc]initWithFrame:CGRectMake(10,10,280,45)];
        [tit_lbl setText:[titles_array objectAtIndex:sample]];
        [btn addSubview:tit_lbl];
        [tit_lbl release];

        UILabel *src_lbl=[[UILabel alloc]initWithFrame:CGRectMake(10,65,280,25)];
        [src_lbl setText:[source_array objectAtIndex:sample]];
        [btn addSubview:src_lbl];
        [src_lbl release];

        x=x+350;
        /*if(index == [titles_array count]-1)
            break;
        index++;        
        */
    }

  return cell;


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:06:58+00:00Added an answer on May 28, 2026 at 2:06 am

    you should use titleArray with NSDictionary objects, where you can provide title to your buttons according to the position in the cell( jus for example, you can use anything to identify your buttons).

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];         
        }
    
        NSDictionary *dict = (NSDictionary*)[titleArray objectAtIndex:indexPath.row]; 
    
        UILabel *tit_lbl=[[UILabel alloc]initWithFrame:CGRectMake(10,10,280,45)];
        [tit_lbl setText:[dict valueForKey:@"titleLabel"]];
        [btn addSubview:tit_lbl];
        [tit_lbl release];  
    
        UILabel *src_lbl=[[UILabel alloc]initWithFrame:CGRectMake(10,65,280,25)];
        [src_lbl setText:[dict valueForKey:@"sourceLabel"]];
        [btn addSubview:src_lbl];
        [src_lbl release];   
    
        return cell;
    }
    

    Hope it helps..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm now learning UITableView class on iOS development. I want to implement three sections
i starter in jqgrid, i want implement inline edit in jqgrid i have this
I have a UITableView and I want to provide the functionality to user to
I have a UITableView. I'm population it from a NSDictionary with arrays for each
I dont want to use a UITableView nor a pickerView because I just have
I want to implement index feature in UITableView as is in the standart contacts
I have a UITableView that displays images associated with contacts in each row. In
I have an UITextField inside an UITableViewCell. I want the textField to return but
I have a UIViewController that I want to use to implement the methods of
I want implement in my software solution an VBA editor but in c# 3.0.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.