0

使用时如何将图像从滚动视图保存到 photalbum

 NSString *imageName = [NSString stringWithFormat:@"image%d.png", i];
    UIImage *image = [UIImage imageNamed:imageName];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

在滚动视图中显示图像视图。

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 < numberOfViews; i++) {
    CGFloat xOrigin = i * self.view.frame.size.width;
NSString *imageName = [NSString stringWithFormat:@"image%d.png", i];
    UIImage *image = [UIImage imageNamed:imageName];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.frame = CGRectMake(xOrigin, 0, self.view.frame.size.width, self.view.frame.size.height);


-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
    case 0:
        UIImageWriteToSavedPhotosAlbum(_imageScrollView._image, self, nil, nil);

        break;

    default:
        break;
}
}

在声明中收到红色消息

   UIImageWriteToSavedPhotosAlbum(_imageScrollView._image, self, nil, nil);

property _image not found on object of type uiscrollview.

感谢帮助。

4

1 回答 1

1

您可以使用单独的指针挂在图像上,或者如果滚动视图是指向它的唯一指针,您可以使用标记找到它:

// right after
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
// give it a tag
imageView.tag = 128;   // any int that is unique relative to other tags in the scroll view

// 用标签找到它...

case 0:
    UIImageView *imageView = (UIImageView *)[imageScrollView viewWithTag:128];
    UIImageWriteToSavedPhotosAlbum(imageView.image, self, nil, nil);

    // notice, there's also no property called _image on an imageView
于 2012-10-09T14:45:53.647 回答