【问题标题】:Retrieving the UIImage of a TTPhotoViewController检索 TTPhotoViewController 的 UIImage
【发布时间】:2010-08-05 10:34:50
【问题描述】:

我有一个运行良好的 TTPhotoViewController 子类。我需要能够提供将下载的图像保存到用户保存的照片目录的选项。我在检索 UIImage 对象时遇到问题。

查看 API 后,我发现 TTPhoto(这是视图控制器的属性之一)实际上并不包含要使用的 UIImage。但是,在 API 中有一个 TTImageView 类,它有一个 UIImage 属性。 TTPhotoView 派生自 TTImageView,在我的视图控制器类中有一个称为“PhotoStatusView”。但是,当我访问它时,我没有返回 UIImage。

有什么想法吗?

【问题讨论】:

  • 对我来说同样的问题,我无法获得全屏视图。我也需要一个解决方案。谢谢

标签: iphone objective-c three20


【解决方案1】:

看看这个网站add save to album functionality

这是来自网站的代码:

    _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);

【讨论】:

    【解决方案2】:

    你应该尝试使用:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-05
      • 1970-01-01
      • 2011-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-22
      相关资源
      最近更新 更多