I have around 1000 ’s of Images, I want show them in my app. What are the possibilities to do that..
The ideas which I’m thinking
1.Saving all images in phone gallery. accessing images form gallery… but It seems not possible as each iOS app has its own sandbox.
2.Saving in my bundle which will increase the memory size.
In android there is a control called “ViewPager”, how can i achieve the same control in iOS ….
Tried scrollview with paging technique but crashes due to memory ....
Please guide me…..
I dont think you can show images from the gallery directly to your application . But you can store it into document directly , for that you have to first pick images from the gallery . you can refer
How to load photos from photo gallery and store it into application project?
And next time when you start application you can load images from the document directory so you dont need to go to the gallery again .
Related
Good morning I am writing an app in Swift 3.1, and one of the features that I would like to provide is that the user can choose their own background for the main View and keep it as part of the application.
I know how to do it at design time, but what I want is to allow the user once they install the application on their devices to select a picture from the photo library and use that as background of the main View. Also I would like to make sure the app doesn't the depend on the photo library after the image was set as background, in other words, I want to copy the image to the app so if the user deletes the image from the photo library, I have a copy of the image as part of the app.
May I ask if what I want to achieve is possible? If so may I ask for some code guidance please?
Thanks in advance.
Yes this can be acheive by following steps:
1) You need to implement UIImagePickerController to select a photo from photos library.
https://turbofuture.com/cell-phones/Access-Photo-Camera-and-Library-in-Swift
2) You need to write a code to save that image in your Application document folder
https://iosdevcenters.blogspot.com/2016/04/save-and-get-image-from-document.html
3) You need to write code to delete the existing image otherwise app size will increase.
Delete files from directory inside Document directory?
4) Get image from Application document folder and add it to your view as background.
https://iosdevcenters.blogspot.com/2016/04/save-and-get-image-from-document.html
I'm creating an iOS app where I need to use many photos(in big resolution). There're almost 400 photos. I want to use them to show in UIImageView on the different pages.
But it's a big bunch of data. So I'm afraid about efficient(not so much) and size of the app itself. What's the best way to use these photos in my iOS app? Does it make sense to create New Image Set and create 1x,2x and 3x photos for each photo or do I have to use other features I don't now about?
UPD1:
The app is about sights. From the tableview user can chose any sight and will be shown screen with 1-3 photos( in CollectionView if there's more than 1 photo) and some text. All data(except photos) I'm getting from sqlite db using CoreData.
The photos are shown on the screen have width equal to screen width (the height 25:38 from width). Width is bigger:)
I want to use big resolution photos because I want show full-size
photos by tap.
Each photo can be 2000px or more on the biggest
side.
The app is an offline app so I want to store photos in the
app. I now just about image assets. But are there other ways to
store photos?
I have an idea to store them in high-resolution and resize to any device(3x, 2x, 1x) to display on the screen. And load high-resolution version of a photo just when user taps on it to show the photo on the full screen.
You cannot load all the photos from the app - this is btw. not possible because of memory issues during loading images.
You should at the beginning think about presenting photos and photos itself.
Do you really need to show photos in big resolution?
What big resolution means? Is that 1024x1024 or native resolution or what?
From where these photos are loaded? App includes it or you'll load them from system library? I see you're writing about image assets, probably you want to keep them in the app.
Do you need to show this images in constant almost 0 time? Maybe keeping it on the backend and fetching and cache when necessary will be better approach. With this you can decrease size of the app.
You can keep in assets only the biggest one - the #3x and resize it on devices that need this in runtime before displaying it.
To keep photos in device's memory you can use NSCache - Apple's Documentation and let system managing the photos. You'll load this and cache in the instance of NSCache and every time you want to access it and get photo you have to check if there is photo or nil and if nil you have to re-load it again from the disk. This will somehow keep your device to not get memory warnings and will automatically managing photos.
Another important thing to think is to how you plan to show the photos. Is is possible to show only 1 at a time or there is more to show? Do you want to present thumbnails of them and after user select some photo show it in the big resolution? Using thumbnails will have less memory footprint.
Update 1:
UPD1: The app is about sights. From the tableview user can chose any places and will be shown screen with 1-3 photos( in CollectionView if there's more than 1 photo) and some text. All data(except photos) I'm getting from sqlite db using CoreData.
The app is an offline app so I want to store photos in the app. I now just about image assets. But are there other ways to store photos?
You don't need assets catalog for this. Just keep it in some directory in the project and load them from /Documents directory when necessary. IMO this will be the best possible approach to store and use locally. Keeping them in the assets will cause that there will be #1x and #2x empty in xcassets file. And keeping them directly in project will be easier to maintain I think.
I want to use big resolution photos because I want show full-size photos by tap.
Each photo can be 2000px or more on the biggest side.
I have an idea to store them in high-resolution and resize to any device(3x, 2x, 1x) to display on the screen. And load high-resolution when user taps on the photo to show photo on the full screen.
Keeping such big photos in the app is poor idea, the app will be big. Even if one photo will be 1mb size which I think is not possible and there are 400 photos the app will be fat.
You should consider keeping them online, really.
You also know all the images in the app so you can create thumbnails in real time and cache them in /Cache directory for later use. The same with big photos for specified device screen resolution. Before displaying resize it and save in /Cache directory for future next time use.
In my app which i am developing now has the Image Gallery where it consist of lot of albums and multiple images per album.
which is the best practice to use for Image Gallery? where i am planning to create a tableview for album listing and a navigating to a new View Controller taping on album. is that good way of creating albums?
and i'm using AFNetwork how to cache the images in the background so that the performance of the application will not effect.
Thanks in Advance.
There are lot if third party image gallery libraries available for iOS. Following are few of them :
FGallery-iPhone
UIPhotoGallery
MWPhotoBrowser
Image-Gallery
If above ones doesn't serve your purpose you can always create a custom gallery view that serves your purpose.
I'm developing an iPhone application, which has similar functionality to Camera Roll. In full size mode (e.g. viewing selected image in full size), I want to display the picture name (image file name).
The problem here: If the user changes the picture name on their PC and upload the picture back to their iPhone, I'm still getting original file name (e.g. "IMG_xxx), while I would like to get the name given by user. If I go to MyPictures on my iPhone, I do see user custom names.
How I can get a custom image name?
Thanks!
simple answer is No. You cannot do what are requesting.
In your app you can call an image whatever you want but once you save it to iPhone/iPad camera roll then it is renamed automatically by iOS. We developers have no control over that behavior.
Now if you were to save that picture in your apps document dir and some how let the user download / upload those pics using iTunes file sharing then perhaps that may work for you.
i want to show all images store in photo library horizontally in UIImageViews at the time of apps launching . i want to show all image without accessing them
This is not possible with the documented API