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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:53:08+00:00 2026-06-18T10:53:08+00:00

I am trying to enter MPMediaItemArtwork Image into UITableView’s cell’s ImageView with following code.

  • 0

I am trying to enter MPMediaItemArtwork Image into UITableView's cell’s ImageView with following code.

MPMediaItemArtwork *artwork = [[[self.arrayOfAlbums objectAtIndex:indexPath.row] representativeItem]valueForProperty:MPMediaItemPropertyArtwork];
    UIImage *artworkImage = [artwork imageWithSize: cell.imageView.bounds.size];

if (artworkImage)
    {
        cell.imageView.image = artworkImage;

    }

    else
    {
        cell.imageView.image = [UIImage imageNamed: @"noArtwork.png"];
    }

It’s okay when i insert Artwork image in UITableView's cell ImageView.

But when my artwork image is too small or big , it’s happened like following pic.
Not in completely fill in cell’s ImageView.

enter image description here

You see that? I want to set Fill with Stretch like iOS Music App

Here is Build-in App Artwork Image that set Completely fill with Stretch

enter image description here

I want to do like that.

So i used cell.imageView.contentMode = UIViewContentModeScaleAspectFill; however it’s not effect.

So how can i do that?
Thanks you for your work.

  • 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-18T10:53:10+00:00Added an answer on June 18, 2026 at 10:53 am

    Try this for calculating a new and fitting image;
    Adjust newRect to the rect of your cell.

    // scale and center the image
    
    CGSize sourceImageSize = [artworkImage size];
    
    // The rectangle of the new image
    CGRect newRect;
    newRect = CGRectMake(0, 0, 40, 33);
    
    // Figure out a scaling ratio to make sure we maintain the same aspect ratio
    float ratio = MAX(newRect.size.width / sourceImageSize.width, newRect.size.height / sourceImageSize.height);
    
    UIGraphicsBeginImageContextWithOptions(newRect.size, NO, 1.0);
    
    // Center the image in the thumbnail rectangle
    CGRect projectRect;
    projectRect.size.width = ratio * sourceImageSize.width;
    projectRect.size.height = ratio * sourceImageSize.height;
    projectRect.origin.x = (newRect.size.width - projectRect.size.width) / 2.0;
    projectRect.origin.y = (newRect.size.height - projectRect.size.height) / 2.0;
    
    [sourceImage drawInRect:projectRect];
    UIImage *sizedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    cell.imageView.image = sizedImage;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to enter an image into a database together with some strings, but
I'm trying to enter edit mode on a specific cell like this: void MainWindow::on_addButton_released()
I'm trying to enter the date '03/20/1985' into a text field called birthday and
I am trying to enter multiple values into a textbox and when I press
I am trying to enter the following to an UPDATE trigger of QuoteItem: UPDATE
I am trying to enter list items into a string. I then want to
Hi, I'm trying to enter the below longitude and latitude into Google Maps but
here i,m trying to enter data into table playlist using information extracted from other
I am trying to enter 5 variables into a MySQL database. Here is the
I have a list of values I am trying to enter into a mysql

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.