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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:33:50+00:00 2026-05-22T17:33:50+00:00

hey people, I put an UIImage into the section header of my UITableVIew. Therefor

  • 0

hey people,
I put an UIImage into the section header of my UITableVIew. Therefor I used some code I found on the internet:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

self.imageViewForImage.image = [helperClass resizeImage:[self.offerItem objectForKey: @"picture"] forSize:CGSizeMake(280.0, 280.0) ];

[self.imageViewForImage.layer setBorderColor: [[UIColor blackColor] CGColor]];
[self.imageViewForImage.layer setBorderWidth: 1.2];

self.imageViewForImage.contentMode = UIViewContentModeBottom;
return self.imageViewForImage;}


-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
{
    if(section == 0)
        return 320;
    return 1.0;
}

At first the image was totally scaled over the complete 320px width of the iphone. But then I found out, that my whole UITableView’s contentMode-property was set to “UIViewContentModeScaleToFill”. So I added a line of code, which tells my UIImageView not to do the scaling. In my case I set it to “UIViewContentModeBottom”.

Problem: This whole thing works, the image is finally shown in the aspected size of 280×280, BUT the border I did around the picture is still stretched / resized to the complete width of the iphone…?!

I can’t figure out how to resolve this issue, because I want the border around the UIImage..

Thanks for any help on this..

edit: does anyone has some idea, what is going wrong here?

  • 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-22T17:33:51+00:00Added an answer on May 22, 2026 at 5:33 pm

    Your UIImageView has a layer the contents of which you set to your image. The size of layer equals to the size of imageView, but size of image is less then it. So when you set contentMode to your view it says to it’s layer to draw layers contents at bottom if contents size is less than layers size. So size of layer (and as consequence size of its frame) are still the same even though you have resized its contents image.

    The problem is that you are trying to resize image, when you should resize UIImageView. This part of code should look something like this:

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        UIView *headerView = [[UIView alloc] init];
    
        self.imageViewForImage.frame = CGRectMake(20, 20, 280, 280);
        self.imageViewForImage.image = [self.offerItem objectForKey:@"picture"];
        self.imageViewForImage.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
    
        [self.imageViewForImage.layer setBorderColor: [[UIColor blackColor] CGColor]];
        [self.imageViewForImage.layer setBorderWidth: 1.2];
    
        [headerView addSubview:self.imageViewForImage];
        return [headerView autorelease];
    }
    

    Hope this’ll help!

    UPDATED: The issue was that view that this method returns is reframed by tableView to fill all the header. So we must make a view that will actually be a header view and place an imageView on it.

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

Sidebar

Related Questions

Hey, I'm using a html form that is used to log people into my
Hey people yesterday i was working on some code and thought that i would
hey people im having trouble with loading my array of strings into a tableview
Hey people I've been searching over the internet for the following problem without success...
Hey people... trying to get my mocking sorted with asp.net MVC. I've found this
Hey I have this code that sends an email with some data sent by
Hey people, why won't this code work? The Facebook API is so bad it's
Hey guys, I've seen a few people bring it up but haven't found a
Hey, I'm working on an iPhone app but I've heard from some people that
Hey I've found a lot of people asking questions similar to mine but not

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.