Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>we cant get UIImagePickerController in landscape...</p> <p>but we can get the images in our device into an array and display them in landscape mode and in portrait mode....itseems same like UIImagePickerController...</p> <p>we should use ALAsset class and ALAssetsLibrary for this..</p> <pre><code>void (^assetEnumerator)(struct ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) { if(result != NULL) { [assets addObject:result]; } }; void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) { if(group != nil) { [group enumerateAssetsUsingBlock:assetEnumerator]; } [self meth]; [activity stopAnimating]; [activity setHidden:YES]; }; assets = [[NSMutableArray alloc] init]; ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; [library enumerateGroupsWithTypes:ALAssetsGroupAlbum usingBlock:assetGroupEnumerator failureBlock: ^(NSError *error) { NSLog(@"Failure");}]; </code></pre> <p>in viewDidLoad</p> <pre><code>-(void)meth { NSLog(@"%i",[assets count]); if(userOrientation==UIInterfaceOrientationPortrait || userOrientation==UIInterfaceOrientationPortraitUpsideDown) { NSLog(@"haii"); [scrollView removeFromSuperview]; scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 460)]; scrollView.backgroundColor=[UIColor whiteColor]; NSLog(@"%i",[assets count]); for (int i = 0; i &lt; [assets count]; i++) { imgBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [imgBtn setFrame:CGRectMake((i%4*80)+2,(i/4*80)+2,75,75)]; imgBtn.tag=i; [imgBtn addTarget:self action:@selector(imageClicked:) forControlEvents:UIControlEventTouchUpInside]; ALAsset *asset=[assets objectAtIndex:i]; [imgBtn setImage:[UIImage imageWithCGImage:[asset thumbnail]] forState:UIControlStateNormal]; [scrollView addSubview:imgBtn]; } scrollView.contentSize = CGSizeMake(320,(([assets count]/4)+1)*300 ); } if(userOrientation==UIInterfaceOrientationLandscapeRight || userOrientation==UIInterfaceOrientationLandscapeLeft) { [scrollView removeFromSuperview]; scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 480,320)]; for (int i = 0; i &lt; [assets count]; i++) { imgBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [imgBtn setFrame:CGRectMake((i%6*80)+2,(i/6*80)+2,75,75)]; imgBtn.tag=i; [imgBtn addTarget:self action:@selector(imageClicked:) forControlEvents:UIControlEventTouchUpInside]; ALAsset *asset=[assets objectAtIndex:i]; [imgBtn setImage:[UIImage imageWithCGImage:[asset thumbnail]] forState:UIControlStateNormal]; [scrollView addSubview:imgBtn]; } scrollView.contentSize = CGSizeMake(480,(([assets count]/4)+1)*300); } [self.view addSubview:scrollView]; } </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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