B4i Library iQBImagePicker - Multiple selection image picker

Discussion in 'iOS Libraries' started by CaptKronos, Mar 16, 2019.

  1. CaptKronos

    CaptKronos Active Member Licensed User

    This is a wrapper for QBImagePicker https://github.com/questbeat/QBImagePicker, an image picker that provides for multiple image and video selection.

    The wrapper includes helper functions which are primarily to copy the selected assets to a folder on the device but a few others have been included since I required them.

    I have noticed that on the Simulator only local (in the DCIM folder) assets can be copied (not sure why) but on a real device I haven't noticed that limitation.

    The list of PHAssetCollectionSubtypes (one or more of which are passed to the load function) can be found here https://github.com/mstg/iOS-full-sd...eworks/Photos.framework/Headers/PhotosTypes.h

    Installation instructions (modified one of Alberto Iglesias' posts since I haven't tried the MAC HOSTED approach):

    - Unzip QBImagePicker.zip into the folder "Libs" in your MAC or in your MAC HOSTED by AnywhereSoftware, normally in "B4i-MacServer\Libs" folder. This will result in iQBImagePicker.h, libiQBImagePicker.a and the folder QBImagePicker.framework being copied to the "Libs" folder.

    -Copy the iQBImagePicker.xml to your custom libraries folder in B4i

    -If you wish to upload an app using iQBImagePicker to the App Store you will need to replace the file Libs\QBImagePicker.framework\QBImagePicker with the file in QBImagePickerARM.zip. The version of QBImagePicker in the zip only contains the ARM architectures. If you don't replace the file, the submission will be rejected by Apple due to the framework having unsupported architectures (i.e. X86).

    iQBImagePicker

    Author: CaptKronos
    Version: 1.0
    • QBImagePicker
      • Events:
        • cancelled
        • picked (assets As List)
      • Functions:
        • convertPHAssetToImage (thePHAsset As PHAsset*) As UIImage*
          <code>dim bmp as bitmap = aQBImagePicker.ConvertPHAssetToImage(assets.Get(i))</code>
        • copyPHAssetToFile (ThePHAsset As PHAsset*, destination As NSString*)
          <code>aQBImagePicker.CopyPHAssetToFile(assets.Get(i), "filename")</code>
        • createAlbum (albumName As NSString*) As BOOL
          <code>aQBImagePicker.createAlbum("myalbum") 'if myalbum already exists another album of the same name will be created</code>
        • existsAlbum (albumName As NSString*) As BOOL
          <code>aQBImagePicker.existsAlbum("myalbum") 'returns true if myalbum exists</code>
        • getImageDataFromAsset (thePHAsset As PHAsset*) As NSDictionary*
          Be careful with this one. Depending on which key you inspect while debugging, it can crash your app.
          <code>Dim dict As Object, dictMap As Map
          dict=aQBImagePicker.getImageDataFromAsset(assets.Get(0))
          dictMap=NSDictionaryToMap(dict)
          Log(dictMap.Get("PHImageFileUTIKey"))</code>
        • getImageURLFromAsset (thePHAsset As PHAsset*) As NSString*
          <code>Dim url As String=QBPicker.getImageURLFromAsset(assets.Get(i))
          url=url.SubString(7) 'convert to regular path and filename</code>
        • initialize (bi As B4I*, eventName As NSString*)
          Initialises the picker.
          Example:<code>aQBImagePicker.initialize("qbimagepicker")</code>
        • load (myViewController As UIViewController*, mediaType As Int, subType As NSArray*, multiSelect As BOOL, minNumber As Int, maxNumber As Int, numColsInPortrait As Int, numColsInLandscape As Int)
          Displays the picker

          MyViewController: The page to host the picker
          MediaType: 1 - images; 2 - videos; 0 - both
          SubType: a list of PHAssetCollectionSubtypes e.g. subType.add(201) is the smartAlbumUserLibrary which is a good starting point
          MultiSelect: True - allows more than one asset to be selected
          MinNumber: The minimum number of assets that must be selected
          MaxNumber: The maximum number of assets that can be selected
          NumColsInPortrait: The number of assets to display horizontally when in portrait (0 for default value)
          NumColsInLandscape: The number of assets to display horizontally when in landscape (0 for default value)
          Example:<code>
          aQBImagePicker.load(pg, 1, subType, True, 1, 100, 0, 0)</code>
        • saveImageFileToAlbum (albumName As NSString*, imageURL As NSString*) As BOOL
          <code>aQBImagePicker.saveImageFileToAlbum("myalbum", File.Combine(File.DirDocuments,"myimage.jpg"))</code>
        • saveImageToAlbum (albumName As NSString*, image As UIImage*) As BOOL
          <code>aQBImagePicker.saveImageToAlbum("myalbum", bmp)</code>
        • saveVideoFileToAlbum (albumName As NSString*, videoURL As NSString*) As BOOL
          <code>aQBImagePicker.saveVideoFileToAlbum("myalbum", File.Combine(File.DirDocuments,"myvideo.mp4"))</code>

    Usage:
    Code:
    Dim aQBImagePicker As QBImagePicker
    Dim subType As List
    subType.Initialize
    subType.Add(
    201)
    aQBImagePicker.initialize(
    "QBImagePicker")
    aQBImagePicker.load(pg, 
    1, subType, True110000)

    Sub QBImagePicker_picked (assets As List)
        
    For i=0 To assets.Size-1
            QBPicker.CopyPHAssetToFile(assets.Get(i), destFilname)
        
    Next
    End Sub
     

    Attached Files:

    Last edited: May 19, 2019
    Almora, Erel, moster67 and 2 others like this.
  2. CaptKronos

    CaptKronos Active Member Licensed User

    I have updated the iQBImagePicker zip with the github pull requests #21, 215 and 216. A few more language translations are now included but the main change is better handling of images residing on iCloud.
     
    MarcoRome likes this.
  3. CaptKronos

    CaptKronos Active Member Licensed User

    Just submitted my first app and received a rejection from Apple due to the QBImagePicker framework having x86 binaries. I have updated the instruction in the OP to address this issue.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice