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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:03:19+00:00 2026-06-15T19:03:19+00:00

I want to images display for cell. but this code display, only white tableview.Why?

  • 0

I want to images display for cell. but this code display, only white tableview.Why? Please tell me. (I use not storyboard.)

TableCell.h

#import <UIKit/UIKit.h>

@interface TableCell : UITableViewCell <UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,retain) UITableView *tableCellView;
@property (nonatomic,retain) NSArray *cellArray;

-(NSString *)reuseIdentifier;

@end

TableCell.m

    #import "TableCell.h"

@implementation TableCell

@synthesize tableCellView;
@synthesize cellArray;


-(NSString *)reuseIdentifier
{
    return @"cell";
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [cellArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [self.tableCellView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }
    for (UIImageView *view in cell.subviews)
    {
        [view removeFromSuperview];
    }

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
    imageView.image = [UIImage imageNamed:[cellArray objectAtIndex:indexPath.row]];
    imageView.contentMode = UIViewContentModeCenter; // 画像サイズを合わせて貼る

    CGAffineTransform rotateImage = CGAffineTransformMakeRotation(M_PI_2); 
    imageView.transform = rotateImage; 

    [cell addSubview:imageView];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 220;
}

@end

TableViewController.h

    #import <UIKit/UIKit.h>

@class TableCell;

@interface TableViewController : UIViewController <UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) TableCell *tableViewCell;
@property (nonatomic, retain) NSArray *titlesArray;
@property (nonatomic, retain) NSArray *peopleArray;
@property (nonatomic, retain) NSArray *thingsArray;
@property (nonatomic, retain) NSArray *fruitsArray;
@property (nonatomic, retain) NSArray *arrays;

@end

TableViewController.m

#import "TableViewController.h"
#import "TableCell.h"

@interface TableViewController ()

@end

@implementation TableViewController

@synthesize tableView;
@synthesize tableViewCell;
@synthesize titlesArray;
@synthesize peopleArray;
@synthesize thingsArray;
@synthesize fruitsArray;
@synthesize arrays;

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.tableView.delegate = self;
    self.tableView.dataSource = self;

    tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] bounds] style:UITableViewStylePlain];
    [self.view addSubview:tableView];

    titlesArray = [[NSArray alloc] initWithObjects:@"People", @"Things", @"Fruits", nil];
    peopleArray = [[NSArray alloc] initWithObjects:@"Gardener.png", @"Plumber.png", @"BusinessWoman.png", @"BusinessMan.png", @"Chef.png", @"Doctor.png", nil];
    thingsArray = [[NSArray alloc] initWithObjects:@"StopWatch.png", @"TrashCan.png", @"Key.png", @"Telephone.png", @"ChalkBoard.png", @"Bucket.png", nil];
    fruitsArray = [[NSArray alloc] initWithObjects:@"Pineapple.png", @"Orange.png", @"Apple.png", nil];

    arrays = [[NSArray alloc] initWithObjects:peopleArray, thingsArray, fruitsArray, nil];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    return [arrays count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return [titlesArray objectAtIndex:section];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 220;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    TableCell *cell = (TableCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil];

        CGAffineTransform rotateTable = CGAffineTransformMakeRotation(-M_PI_2);
        tableViewCell.tableCellView.transform = rotateTable;
        tableViewCell.tableCellView.frame = CGRectMake(0, 0, tableViewCell.tableCellView.frame.size.width, tableViewCell.tableCellView.frame.size.height);

        tableViewCell.cellArray = [arrays objectAtIndex:indexPath.section];

        tableViewCell.tableCellView.allowsSelection = YES;
        cell = tableViewCell;

    }

    return cell;
}

@end

AppDelegate.m

TableViewController *tvc = [[TableViewController alloc] init];
    self.window.rootViewController = tvc;
  • 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-06-15T19:03:20+00:00Added an answer on June 15, 2026 at 7:03 pm

    UITableViewCell by default already has support for images. You do not need to to add a new UIImageView as a subview …

    So instead of this:

    for (UIImageView *view in cell.subviews)
    {
        [view removeFromSuperview];
    }
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
    imageView.image = [UIImage imageNamed:[cellArray objectAtIndex:indexPath.row]];
    imageView.contentMode = UIViewContentModeCenter; // 画像サイズを合わせて貼る
    
    CGAffineTransform rotateImage = CGAffineTransformMakeRotation(M_PI_2); 
    imageView.transform = rotateImage; 
    
    [cell addSubview:imageView];
    

    Write this:

    cell.imageView.image = [UIImage imageNamed:[cellArray objectAtIndex:indexPath.row]];
    

    Oh, I now notice that LOTS OF OTHER STUFF is wrong with your code! Sorry to say that. Other stuff you need to change:

    1. Copy this method from your TableCell to your TableViewController: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath and remove the existing one
    2. DELETE the TableCell class

    I see you’re also doing rotation… but leave that out for now. First try to make it work and THEN worry about rotation of the image.

    Can I maybe advise you to read a book on iOS development? It seems as if you don’t know what you’re doing at all 🙁

    But I do like to help you out. Can you maybe put all your code on http://www.github.com and invite me as a collaborator? My username is tomvanzummeren. I can make this app work for you.

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

Sidebar

Related Questions

I want to display images in a TableView . I can display one image
I want to display about 5-8 images on my page, one by one, but
I have some text/images that I only want to display in the normal state
I want to display background image on tableview cell... on that i need to
I want to display images on a .net page which I load from database
I want to integrate the Cover Flow for the images display in my iPhone
I have a sprite sheet and I want to display images next to each
I am parsing the public timeline xml from twitter and want to display images
Just looking for a good PHP Image Library, I want to display images with
I have a list of images which I want to display in a page.

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.