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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:11:32+00:00 2026-06-14T10:11:32+00:00

I am new to oop and objective-c. I have a collectionView which loads photos

  • 0

I am new to oop and objective-c. I have a collectionView which loads photos from my phone. I want to segue to another ViewController so that my asset is displayed @ full resolution.I followed this post: set UIImageView.image in prepareForSegue by Rob Mayoff and came up with this, here is my code for the main VC :

 - (void)viewDidLoad
    {
        [super viewDidLoad];

        void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
        {
            if (result != NULL)
            {
                NSLog(@"See Asset: %@", result);
                [_gallery addObject:result];
            }

        };




        void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) =  ^(ALAssetsGroup *group, BOOL *stop)
        {
            if(group != nil)
            {
                [group enumerateAssetsUsingBlock: assetEnumerator];

            }

           [self.collectionView reloadData];
        };

        _gallery = [[NSMutableArray alloc]init];

        _library = [[ALAssetsLibrary alloc] init];

        [_library enumerateGroupsWithTypes: ALAssetsGroupAlbum
                               usingBlock: assetGroupEnumerator
                             failureBlock: ^(NSError *error)
         {
             NSLog(@"Failure");
         }];
    }





    -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
    {

        return 1;

    }


    -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
    {
        return _gallery.count;

    }


    -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
    {

        ViewControllerCell *myCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"myCell" forIndexPath:indexPath];



        _asset = [_gallery objectAtIndex:indexPath.row];


        _photo =[UIImage imageWithCGImage:[_asset thumbnail]] ;

        myCell.myImage.image = _photo;

        return myCell;
    }



    -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
    {
        _asset = [_gallery objectAtIndex:indexPath.row];
        _photo = [UIImage imageWithCGImage:[_asset thumbnail]];
        ALAssetRepresentation *rep = [_asset defaultRepresentation];
        CGImageRef ref = [rep fullResolutionImage];
        _img = [UIImage imageWithCGImage: ref];


    }

     //the segue is set to modal
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {

        if ([segue.identifier isEqualToString:@"ShowPhoto"]) {


           PhotoZoomController *photoZoom = segue.destinationViewController;

            photoZoom.object = sender;


        }
    }

Now to show my full image I do this in my viewDidLoad method in the destination VC :

- (void)viewDidLoad
{
    ViewController *vc = [[ViewController alloc] init];

    _image = vc.img;

     [super viewDidLoad];


    _largePhoto.image = _image;   / *largePhoto is the UIImageView @property declared        
                                    in destination VC.h */

}

I am getting a blank imageView. I certainly have done something wrong and really need your help. I just don’t know what to do anymore Thanks in advance.

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

    I think you misunderstood how prepareForSegue: method works. It basically provides you a possibility to interact with viewController to which you are navigating to, like setting a property. So your PhotoZoomController should have a property UIImageView to which you pass the image. Then you can do something like this:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if ([segue.identifier isEqualToString:@"ShowPhoto"]) {
               PhotoZoomController *photoZoom = segue.destinationViewController;
                photoZoom.imageView = myCreatedImageView;
            }
        }
    

    This way once your modal view is displayed, its UIImageView property should be set properly. There is no need to create new view controller ViewController *vc, like you do.

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

Sidebar

Related Questions

I'm brand new to OOP and I have a question that's gotta be pretty
I am new to OOP and I have recently asked question , which have
I'm new to OOP in PHP, is that to seems correct ? class whatever
I'm very new to OOP, and in the program I'm working on, I have
(New to Objective-C, but well versed in C/C++). Presently I have an Objective-C class
I just started learning Objective-C and OOP ... so I have very stupid question
New to OOP with Perl, and just had a quick question. I have this
New to OOP in PHP One of my functions requires another function to be
I'm pretty new in OOP but have to develop a big project... Just for
I'm pretty new to OOP, so any help is appreciated. I have a class

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.