Getting UIImage TTPhotoViewController

I have a subclass of TTPhotoViewController that works great. I need to provide the ability to save the image uploaded to the user's saved photos folder. I'm having trouble loading a UIImage object.

After looking at the API, I saw that TTPhoto(which is one of the properties of the view controller) does not actually contain UIImage to use. However, there is a class in the API TTImageViewthat has a property UIImage. TTPhotoViewcomes from TTImageView, and there is one of them, in my opinion, a controller class called "PhotoStatusView". However, when I access this, I do not return UIImage.

Any ideas?

+3
source share
2 answers

Check this site out to add save to album functionality

Here is the code from the site:

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

    }

and this one

   - (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);
+1
source

You should try:

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

Source: https://habr.com/ru/post/1758185/


All Articles