Note that there are some explanatory texts on larger screens.

plurals
  1. POcontentoffset in scrollview
    primarykey
    data
    text
    <p>How can i set the contentoffset for image to track down which image user is on and selected to save it to phot album.</p> <pre><code> UIScrollView *imageScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; imageScrollView.pagingEnabled = YES; NSInteger numberOfViews = 61; for (int i = 0; i &lt; numberOfViews; i++) { CGFloat xOrigin = i * self.view.frame.size.width; NSString *imageName = [NSString stringWithFormat:@"image%d.png", i]; _image = [UIImage imageNamed:imageName]; _imageView = [[UIImageView alloc] initWithImage:_image]; _imageView.frame = CGRectMake(xOrigin, 0, self.view.frame.size.width, self.view.frame.size.height); UILongPressGestureRecognizer *gestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; imageScrollView.userInteractionEnabled = YES; [imageScrollView addGestureRecognizer:gestureRecognizer]; gestureRecognizer.delegate = self; [gestureRecognizer release]; [imageScrollView addSubview:_imageView]; imageScrollView.contentSize = CGSizeMake(self.view.frame.size.width * numberOfViews, self.view.frame.size.height); </code></pre> <p>Edit:</p> <pre><code>imageScrollView.contentOffset = CGPointMake(CGFloat x, CGFloat y); </code></pre> <p>in the contentoffset not sure what to put so that image can be tracked the user is on and selected to save to photo album</p> <pre><code>- (void)handleLongPress:(UILongPressGestureRecognizer*)gestureRecognizer{ if (gestureRecognizer.state == UIGestureRecognizerStateBegan){ UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Save Photo", nil]; actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent; [actionSheet showInView:self.view]; [actionSheet release]; }} -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { switch (buttonIndex) { case 0: [self savePhoto]; break; default: break; } -(void)savePhoto{ CGPoint location = [gesture locationInView:_imageView]; if (CGRectContainsPoint(_imageView.bounds, location)){ UIImageWriteToSavedPhotosAlbum(_image, self, @selector(image: didFinishSavingWithError:contextInfo:), nil); }}} </code></pre> <p>Any ideas will be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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