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

  • Home
  • SEARCH
  • 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 4624404
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:07:30+00:00 2026-05-22T03:07:30+00:00

Can anybody tell me how to create a tableview with two cells by colums

  • 0

Can anybody tell me how to create a tableview
with two cells by colums in the Iphone SDK??

order in like this :

  _____________
  |  1  |   2  |
  |_____|______|
  |  3  |   4  |
  |_____|______|

Best regards

  • 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-22T03:07:30+00:00Added an answer on May 22, 2026 at 3:07 am

    In ios UITableView you can only have one column/cell. If you want more propertyes, in a same cell you need to create a custom table view cell by subcalssing UITableViewCell. In interface builder you can customize the layout. TUTORIAL: http://adeem.me/blog/2009/05/30/iphone-sdk-tutorial-part-6-creating-custom-uitableviewcell-using-interface-builder-uitableview/

    Concrete example for your problem:

    the .h file:

     #import <UIKit/UIKit.h>
    
    
    @interface MyCell : UITableViewCell {
        UIButton * column1;
        UIButton * column2;
    
        UILabel* column1_label1;
        UILabel* column1_label2;
    
        UILabel* column2_label1;
        UILabel* column2_label2;
    }
    
    @property (nonatomic,retain) UIButton * column1;
    @property (nonatomic,retain) UIButton * column2;
    
    @property (nonatomic,retain) UILabel* column1_label1;
    @property (nonatomic,retain) UILabel* column1_label2;
    
    @property (nonatomic,retain) UILabel* column2_label1;
    @property (nonatomic,retain) UILabel* column2_label2;
    
    @end
    

    the .m file:

    #import "MyCell.h"
    
    
    @implementation MyCell
    
    @synthesize column1,column1_label1,column1_label2,column2,column2_label1,column2_label2;
    
    - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            column1 = [UIButton buttonWithType: UIButtonTypeCustom];
            column1.tag = 1;
            column1.autoresizingMask = 292;
    
            column1.backgroundColor = [UIColor redColor];
            column1.frame = CGRectMake(0, 0, self.contentView.bounds.size.width/2,  self.contentView.bounds.size.height);
    
    
            column1_label1 = [[UILabel alloc] initWithFrame: CGRectMake(column1.bounds.size.width*1/5,
                                                                                 0,
                                                                                 column1.bounds.size.width*4/5,
                                                                                 column1.bounds.size.height/2)];
    
            column1_label1.backgroundColor = [UIColor redColor];
            [column1 addSubview:column1_label1]; 
    
            column1_label2 = [[UILabel alloc] initWithFrame: CGRectMake(column1.bounds.size.width*1/5,
                                                                                 column1.bounds.size.height/2,
                                                                                 column1.bounds.size.width*4/5,
                                                                                 column1.bounds.size.height/2)];
    
            column1_label2.backgroundColor = [UIColor greenColor];
            [column1 addSubview:column1_label2]; 
    
            [self.contentView addSubview: column1]; 
    
    
    
    
            column2 = [UIButton buttonWithType: UIButtonTypeCustom];
    
    
            column2.tag = 2;
            column2.autoresizingMask = 292;
    
            column2.backgroundColor = [UIColor greenColor];
            column2.frame = CGRectMake(self.contentView.bounds.size.width/2, 0, self.contentView.bounds.size.width/2,  self.contentView.bounds.size.height);
    
            column2_label1 = [[UILabel alloc] initWithFrame: CGRectMake(column2.bounds.size.width*1/5,
                                                                                 0,
                                                                                 column2.bounds.size.width*4/5,
                                                                                 column2.bounds.size.height/2)];
    
            column2_label1.backgroundColor = [UIColor redColor];
            [column2 addSubview:column2_label1]; 
    
            column2_label2 = [[UILabel alloc] initWithFrame: CGRectMake(column2.bounds.size.width*1/5,
                                                                                 column2.bounds.size.height/2,
                                                                                 column2.bounds.size.width*4/5,
                                                                                 column2.bounds.size.height/2)];
    
            column2_label2.backgroundColor = [UIColor greenColor];
            [column2 addSubview:column2_label2]; 
    
    
            [self.contentView addSubview: column2];
        }
        return self;
    }
    
    - (void)setSelected:(BOOL)selected animated:(BOOL)animated
    {
        [super setSelected:selected animated:animated];
    
        // Configure the view for the selected state
    }
    
    - (void)dealloc
    {
        [super dealloc];
    }
    
    @end
    

    the usage in UITableViewController:

       - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    
        // Return the number of sections.
        return 1;
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    
        // Return the number of rows in the section.
        return 40;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        MyCell * mycell2 = ((MyCell*)cell);
        if (cell == nil) {
            cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    
            [mycell2.column1 addTarget:self action:@selector(column1Selected:) forControlEvents:UIControlEventTouchUpInside];
            [mycell2.column2 addTarget:self action:@selector(column1Selected:) forControlEvents:UIControlEventTouchUpInside];        
        }
    
        // Configure the cell...
    
        mycell2.column1_label1.text = @"column1_label1";
        mycell2.column1_label2.text = @"column1_label2";
        mycell2.column1.tag = indexPath.row*2;
        mycell2.column2_label1.text = @"column2_label1";
        mycell2.column2_label2.text = @"column2_label2";
        mycell2.column2.tag = indexPath.row*2 +1;
        return cell;
    }
    
    - (void) column1Selected: (id) sender
    {
    
        UIAlertView *alert = [[ UIAlertView alloc]                          
                              initWithTitle: @" Alert"                          
                              message: [NSString stringWithFormat: @"button %d",((UIButton *) sender).tag]
                              delegate: nil                          
                              cancelButtonTitle: @" OK"                          
                              otherButtonTitles: nil];    
        [alert show] ;
        [alert release];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody tell my why this doesn't work in the Android emulator? From the
Can anybody tell me how to search for available iPhone/iPod devices on a network
can anybody tell me what's the point if any for a javascript function like
can anybody tell me why this works <g:each var=n in=${com.pp.News.list()}> <h2>${n.t}</h2> <p>${n.tx}</p> </g:each> but
Can anybody tell me, how do i create website which supports various screen resolution
Today I saw the following syntax. Can anybody tell me the meaning of this:
Can anybody tell me how to create an editable textbox with rounded corners in
Can anybody tell me how to find or create a binding to OpenCV for
Can anybody tell me why is this REST service not working? namespace WCFRestExample {
Can anybody tell me how to do the following: Create Nodes Enable/Disable Individual Nodes

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.