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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:36:33+00:00 2026-06-14T21:36:33+00:00

I have an array of UIImageViews: NSMutableArray *imagesArray = [[NSMutableArray alloc] init]; [imagesArray addObject:smallBox];

  • 0

I have an array of UIImageViews:

NSMutableArray *imagesArray = [[NSMutableArray alloc] init];
[imagesArray addObject:smallBox];
[imagesArray addObject:medBox];
[imagesArray addObject:largeBox];
[imagesArray addObject:xlBox];

These boxes are being moved on the screen. I would like the array sorted so that whichever box is on the left side of the screen (x position) is in the first position of the array etc. I think I would be able to figure it out if I knew how to access the properties of the images while in the array. I tried using code like imagesArray[0].frame.origin.x; but that does not work. Any help would be appreciated.

  • 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-14T21:36:34+00:00Added an answer on June 14, 2026 at 9:36 pm

    I’d do it like this:

    NSSortDescriptor *desc = [NSSortDescriptor sortDescriptorWithKey:@"frame.origin.x" ascending:YES];
    [imagesArray sortUsingDescriptors:@[desc]];
    

    That’s assuming that all the objects in the array are views — make sure that smallBox, medBox, etc. are all instances of UIImageView and not UIImage. Also, note that in order for the image views’ x coordinate to be sort the way you want them to, they should all be subviews of the same superview. If they’re not, you’re not comparing apples to apples. If the views are not all subviews of the same view, you’ll need to write a comparator that first converts the view’s frame to screen coordinates before comparing.

    Your expression (imagesArray[0].frame.origin.x) should give you the x coordinate of the view at imagesArray[0], and if it doesn’t it’d be helpful to know how/why it’s failing.

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

Sidebar

Related Questions

NSMutableArray *nameArray = [[NSMutableArray alloc] init]; [nameArray addObject:@abc]; [nameArray addObject:@cdf]; [nameArray addObject:@jkl]; //Use a
I have Several UIImageViews in a NSMutableArray. They are all in the superView. I
In my code I have an array of objects which are UIImageViews with UIImages
I want to make an array with a bunch of UIImageViews I have in
I have several objects in an array. These objects are from a UIImageView subclass.
I have NSMutableArray containing UIImageViews and NSArray containing UIImages. The arrays are of equal
I have an array of UIImageViews . I want to apply a shadow to
I have array INPUTFILES with n files INPUTFILES=( file_0 ... files_n-1 ) And i
I have array of hashes: @array = [{:id => 1, :status=>R}, {:id => 1,
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>

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.