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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:52:47+00:00 2026-05-26T12:52:47+00:00

I’m loading an image in to an UITableView through a simple cell.imageView.image = [UIImage

  • 0

I’m loading an image in to an UITableView through a simple

cell.imageView.image = [UIImage imageNamed:@"prem.jpg"]; 

However, what I’ve learnt from my limited time with xcode things arent normally that easy! I want to have the image in there take up the fullsize of the image which is about 280 wide and 150 tall. From googling I might have to build a custom cell and put the image in there and then load that custom cell? I’ve not done anything like that before and it seems a bit annoying just to load one image. Is there an alternative?

To put in context, I have 3 sections in the tableview top section will be the image, and the other two are arrays loaded from XML files. If I do a custom cell I have to do a seperate xml call to get the image url before it goes through so I’d really like to avoid that if possible?

Really looking for any pointers you can offer. Thanks a lot

Tom

Edit: cellforrowindexpath as requsted:

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

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }

    if(indexPath.section == 0)


        cell.imageView.image = [UIImage imageNamed:@"prem.jpg"];




    if(indexPath.section == 1)

        cell.textLabel.text = [arryTableData objectAtIndex:indexPath.row];


    else if(indexPath.section == 2)
        cell.textLabel.text = [arryTableActions objectAtIndex:indexPath.row];

    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-26T12:52:47+00:00Added an answer on May 26, 2026 at 12:52 pm

    There is no need to create a custom cell subclass. I am assuming you have a single cell in section 0 and a variable number of cells in sections 1 and 2.

    You should be using a different cell reuse identifier for your cell in section 0 as it contains an image view and the others don’t – this will show up in your later sections when the cells are recycled otherwise.

    I’d try something like this:

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    {      
        static NSString *CellIdentifierText = @"TextCell";
        static NSString *CellIdentifierImage = @"ImageCell";
    
        if (indexPath.section == 0)
        {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierImage];
            // I am assuming this image never changes and there is one row in this section! If it does change, use viewWithTag to get hold of the image view.
            if (cell == nil) 
            {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifierImage] autorelease];
                       UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,250,180)];              
                       myImageView.tag = 1;
                 myImageView.image = [UIImage imageNamed:@"prem.jpg"];
                [cell addSubview:myImageView];
                           [myImageView release];
            }
            return cell;
        }
        else
        {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierText];
            if (cell == nil) 
            {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifierText] autorelease];
            }      
            if(indexPath.section == 1)          
                cell.textLabel.text = [arryTableData objectAtIndex:indexPath.row];       
            else if(indexPath.section == 2)         
                cell.textLabel.text = [arryTableActions objectAtIndex:indexPath.row];      
            return cell;   
        }
    }   
    

    Make sure you are adding the image to the newly created image view and not cell.imageView as the latter is a read-only property which is over to the left side, I’m not sure you can resize it.

    You will also need to set the height for your cell, as it is taller than the standard. This will be in the tableView:heightForRowAtIndexPath: delegate method.

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

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.