TTPhotoViewController的UIImage检索

3
我有一个TTPhotoViewController子类,运行得很好。我需要能够将下载的图像保存到用户的保存照片目录中的选项。我无法实际检索UIImage对象。
浏览API后,我发现视图控制器的属性之一TTPhoto实际上不包含可用的UIImage。但是,在API中有一个TTImageView类,它具有UIImage属性。TTPhotoView派生自TTImageView,并且在我的视图控制器类中有一个名为“PhotoStatusView”的这样一个对象。但是当我访问它时,我没有得到UIImage对象。
有任何想法吗?

我也遇到了同样的问题,无法全屏查看。我也需要一个解决方案。谢谢。 - user514488
2个回答

1

请查看此网站 添加保存到相册功能

以下是该网站的代码:

    _clickActionItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
                        UIBarButtonSystemItemAction
                        //TTIMAGE(@"UIBarButtonReply.png")
     target:self action:@selector(clickActionItem)];



  UIBarButtonItem* playButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:
    UIBarButtonSystemItemPlay target:self action:@selector(playAction)] autorelease];
  playButton.tag = 1;


  UIBarItem* space = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:
   UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease];
  _toolbar = [[UIToolbar alloc] initWithFrame:
    CGRectMake(0, screenFrame.size.height - TT_ROW_HEIGHT,
               screenFrame.size.width, TT_ROW_HEIGHT)];
  _toolbar.barStyle = self.navigationBarStyle;
  _toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth
                              | UIViewAutoresizingFlexibleTopMargin;

    NSString *searchCaption = @"Photo from networked";
    NSRange range = [[_centerPhoto caption] rangeOfString:searchCaption];

    if (range.location == NSNotFound) {
        _toolbar.items = [NSArray arrayWithObjects:
    space, _previousButton, space, _nextButton, space,_clickActionItem, nil];
  [_innerView addSubview:_toolbar];
    }else{
        _toolbar.items = [NSArray arrayWithObjects:
                          space, _previousButton, space, _nextButton, space, nil, nil];
        [_innerView addSubview:_toolbar];

    }

和这个

   - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{

    if(6 == actionSheet.tag)
    {
        if(0 == buttonIndex)//save page

        {           

            NSLog(@"photo: %@", [_centerPhoto URLForVersion:TTPhotoVersionLarge]);


            NSURL    *aUrl  = [NSURL URLWithString:[_centerPhoto URLForVersion:TTPhotoVersionLarge]];
            NSData   *data = [NSData dataWithContentsOfURL:aUrl];
            UIImage  *img  = [[UIImage alloc] initWithData:data];

            NSLog(@"photo:class %@", [img class]);

            UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);

0

你应该尝试使用:

UIImage *image = [[TTURLCache sharedCache] imageForURL:URL];

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接