OceanLabs / iOS-Print-SDK

iOS Print SDK. Easily add print on demand functionality to your app within minutes! Print Postcards, Magnets, Photo Prints, Posters, Stickers, T-Shirts, PhotoBooks, etc.
https://www.kite.ly
111 stars 33 forks source link

All items OLAssets selected #277

Closed BillyJohn3 closed 7 years ago

BillyJohn3 commented 7 years ago

I have function in my app to collect up all the URLs of images I wish to display and make an OLAsset assetWithURL for each URL. But, when I present the view controller and pass it this array of OLAssets when the user comes to select the images they with to use (say for a print) all the images in the Array I passed are selected. How can I make it default to not having any selected?

Also how can I hide the 'camera role' selecting ability?

kkarayannis commented 7 years ago

Hi @BillyJohn3

You can do that by initializing OLKiteViewController without any assets:

OLKiteViewController *vc = [[OLKiteViewController alloc] initWithAssets:@[]];

and add your URL assets in the following way:

OLImagePickerProviderCollection *dogsCollection = [[OLImagePickerProviderCollection alloc] initWithArray:@[[OLAsset assetWithURL:[NSURL URLWithString:@"https://s3.amazonaws.com/psps/sdk_static/5.jpg"]], [OLAsset assetWithURL:[NSURL URLWithString:@"https://s3.amazonaws.com/psps/sdk_static/6.jpg"]], [OLAsset assetWithURL:[NSURL URLWithString:@"https://s3.amazonaws.com/psps/sdk_static/7.jpg"]], [OLAsset assetWithURL:[NSURL URLWithString:@"https://s3.amazonaws.com/psps/sdk_static/8.jpg"]]] name:@"Dogs"];

[vc addCustomPhotoProviderWithCollections:@[dogsCollection] name:@"Dogs" icon:[UIImage imageNamed:@"dog"]];

You can add a second OLImagePickerProviderCollection to organize your images in albums (1st attached screenshot) or you can call addCustomPhotoProviderWithCollections:name:icon: a second time to add a second tab (2nd attached screenshot).

Finally, you can hide the camera roll like this:

vc.disableCameraRoll = YES;

My examples are written in Objective-c but it should work similarly in Swift.

simulator screen shot 30 mar 2017 4 01 52 pm simulator screen shot 30 mar 2017 4 01 10 pm

BillyJohn3 commented 7 years ago

Positively amazing, thanks.

Is it the case that I can only use OLAssetWithURL for jpeg images? I'm getting an error 'JPEGDecompressSurface : Picture decode failed e00002d1'

Thanks once again, adding onto an app really is as easy is it says.

kkarayannis commented 7 years ago

PNGs should also work fine. If this continues to be a problem, please open a new issue and I'll look into it.