Note that there are some explanatory texts on larger screens.

plurals
  1. POSEGUE and show large image in another VC
    primarykey
    data
    text
    <p>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: <a href="https://stackoverflow.com/questions/11515643/set-uiimageview-image-in-prepareforsegue">set UIImageView.image in prepareForSegue</a> by Rob Mayoff and came up with this, here is my code for the main VC : </p> <pre><code> - (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; } } </code></pre> <p>Now to show my full image I do this in my viewDidLoad method in the destination VC :</p> <pre><code>- (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 */ } </code></pre> <p>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. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload