0

I need show the image from https (ex. https://ton.twitter.com/1.1/ton/data/dm/433966760199725056/433966760212332544/du3THdSe.png) by UIImageView in my iOS app. This image opens in browser, but does not show in UIImageView by using these methods:

 NSURL *url = [NSURL URLWithString:@"https://ton.twitter.com/1.1/ton/data/dm/433966760199725056/433966760212332544/du3THdSe.png"];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
imageView.image = image;

or

// using SDWebImage
[imageView setImageWithURL:[NSURL URLWithString:@"https://ton.twitter.com/1.1/ton/data/dm/433966760199725056/433966760212332544/du3THdSe.png"] placeholderImage:nil];

How can I display this image?

Xu Yin
  • 3,932
  • 1
  • 26
  • 46
Alex
  • 2,100
  • 19
  • 26

1 Answers1

2

It won't display until you login into twitter with your app. The app can only display the image when you have an open Session with Twitter.

Try calling that URL with your Chrome or Safari in Incognito/Private Mode and see what happens!

You will be redirected to the login page of Twitter. Same thing happens with your app.

Hope that helps.

Cheers, Sebastian

Sebastian Borggrewe
  • 1,260
  • 4
  • 13
  • 25
  • Also pay attention to the frame of the imageview. If you do not define it somewhere (can be IB) it will have size (0,0) and the image still wont show up – mrosales Feb 13 '14 at 17:50
  • Oh, yes. But there is one nuance. I can't show dialog or open session. Maybe it will help if I pass in parameters access token or some anything? – Alex Feb 13 '14 at 18:01
  • You can find all about the twitter api authentification process in their docs: https://dev.twitter.com/docs/auth/application-only-auth – Sebastian Borggrewe Feb 14 '14 at 12:09