Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum asset selection for photos and videos (separate) #95

Open
coder123-star opened this issue Nov 21, 2020 · 2 comments
Open

Maximum asset selection for photos and videos (separate) #95

coder123-star opened this issue Nov 21, 2020 · 2 comments

Comments

@coder123-star
Copy link

Similar to an app like twitter I would like to only allow users to upload one video however they can select multiple images and upload them. I don't know how to do this though since there is only maximum and minimum selection for all assets.

@gezihuzi
Copy link
Contributor

gezihuzi commented Dec 13, 2020

You can do this by delegate the method func assetsPicker(controller: AssetsPickerViewController, shouldSelect asset: PHAsset, at indexPath: IndexPath) -> Bool to achieve this.

Look like this:

   func assetsPicker(controller: AssetsPickerViewController, shouldSelect asset: PHAsset, at indexPath: IndexPath) -> Bool {
        if controller.selectedAssets.count >= 1 {
            return false
        }
        return true
    }

@Priyanka-gupta-pcg
Copy link

Priyanka-gupta-pcg commented Dec 17, 2020

found solution -

func assetsPicker(controller: AssetsPickerViewController, shouldSelect asset: PHAsset, at indexPath: IndexPath) -> Bool {
     // can limit selection count
     if asset.mediaType == .video {
         if controller.selectedAssets.count > 4 {
             return false
         }
     }
     if asset.mediaType == .image {
         if controller.selectedAssets.count > 7 {
             return false
         }
     }
     return true
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants