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 7656141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:41:34+00:00 2026-05-31T12:41:34+00:00

I created a subclass of UITableViewCell and added two identical UIView s that have

  • 0

I created a subclass of UITableViewCell and added two identical UIViews that have exactly the same format.

MyTableViewCell:

 UIView *leftView    = [[UIView alloc ] initWithFrame:CGRectMake(0, 0, 160, 100)];
 UIView *rightView   = [[UIView alloc ] initWithFrame:CGRectMake(160, 0, 160, 100)]; 
 [self.contentView addSubview:leftView];
 [self.contentView addSubview:rightView];

Each time I need to assign two values when indexPath.row indicates only one index. This is my current code:

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

    if (indexPath.row %2) {
        cell.label1.text = [array  objectAtindex:indexPath.row]  objectForKey:@"name"];
        cell.label2.text =[array  objectAtindex:indexPath.row]  objectForKey:@"name"]; 
     }
}

Cell layout:

   |------------|--------------|
   |     1      |      2       |
   -----------------------------
   |     3      |      4       |
   -----------------------------
   |     5      |      6       |
   -----------------------------

The result is that cells 2,3,6 are empty and cells 1,4,5 filled. I have no idea how to populate data into the two same UIViews.

  • 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-31T12:41:35+00:00Added an answer on May 31, 2026 at 12:41 pm

    Assuming your array contains exactly twice as many items as the table has rows, it should work like this:

    NSUInteger indexForField1 = indexPath.row * 2;
    NSUInteger indexForField2 = indexPath.row * 2 + 1;
    cell.label1.text = [array  objectAtindex:indexForField1]  objectForKey:@"name"];
    cell.label2.text =[array  objectAtindex:indexForField2]  objectForKey:@"name"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a subclass of UITableViewController that is used as the custom class
I created a subclass of UIView that overrides drawRect: and uses AddArcToPoint() to draw
I have created a class named ListCell which is a subclass of UITableViewCell .
I have created a subclass of UIView and I would like to have it
I have a subclass of UITableViewCell that I create for a UITableView. Let's say
I've created a UITableViewCell subclass as below. All I've done is added a label
I created a subclass from UIView #import <UIKit/UIKit.h> @interface MeeSelectDropDownView : UIView { UILabel
I have created a subclass of UIImageView and I am handling the touches for
I created an UIViewController subclass, and figured out that the default implementation of -loadView
I've created a subclass of UITableViewCell . Until now, I've only been using cells

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.