iOS Question iQBImagePicker.h not on hosted builder

LucasHeer

Active Member
Licensed User
Longtime User
Good afternoon!

Would it be possible to add iQBImagePicker to the hosted builder?
B4X:
error: 'iQBImagePicker.h' file not found (in target 'B4iProject' from project 'B4iProject')

https://www.b4x.com/android/forum/threads/iqbimagepicker-multiple-selection-image-picker.103780/

I am about to test on the local builder. Does anybody know if this library is deprecated? If so, is there another solution to allowing the user to select multiple photos on the device at once?

Thank you so much!!


Edit---

I ended up using PHPickerViewController instead (iOS 14+) to pick multiple images:
B4X:
#If OBJC

#import <Photos/Photos.h>
#import <PhotosUI/PhotosUI.h>

- (void) showPicker: (UIViewController *) page API_AVAILABLE(ios (14))
{
    dispatch_async(dispatch_get_main_queue(), ^{
        PHPickerConfiguration *config = [[PHPickerConfiguration alloc] init];
        config.selectionLimit = 30;
        config.filter = [PHPickerFilter imagesFilter];

        PHPickerViewController *pickerViewController =
            [[PHPickerViewController alloc] initWithConfiguration:config];
        pickerViewController.delegate = (id) self;

        [page presentViewController: pickerViewController animated: YES completion: nil];
    });
}

- (void) picker: (PHPickerViewController *) picker
didFinishPicking: (NSArray <PHPickerResult *> *) results API_AVAILABLE (ios (14))
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [picker dismissViewControllerAnimated:YES completion:nil];
        [self.bi raiseEvent:nil event:@"phpicker_finished:" params:@[@((int)results.count)]];
    });

    for (PHPickerResult *result in results)
    {
        [result.itemProvider loadObjectOfClass:[UIImage class]
                             completionHandler:^(__kindof id<NSItemProviderReading> _Nullable object,
                                                 NSError * _Nullable error)
        {
            dispatch_async(dispatch_get_main_queue(), ^{
                if (error == nil && [object isKindOfClass:[UIImage class]]) {
                    [self.bi raiseEvent:nil event:@"phpicker_item:" params:@[object]];
                } else {
                    // easiest: just skip bad items (no event)
                    // or if you prefer: send NSNull and treat it as Null in B4i
                    // [self.bi raiseEvent:nil event:@"phpicker_item:" params:@[[NSNull null]]];
                }
            });
        }];
    }
}

#End If

#If B4I
'Class_Globals:


Private Sub PHPicker_Finished(Count As Int)
    Log($"PHPicker finished, selected=${Count}"$)
End Sub

Private Sub PHPicker_Item(Item As Object)
    If Item = Null Then Return
    Dim img As Bitmap = Item
    Dim src As B4XBitmap = img
    
    AddPickedImageFromBitmap(src)
End Sub
#End If

Private Sub pnl_openphotos_Click
    If vehicle_media_list.IsInitialized = False Then vehicle_media_list.Initialize
    #If B4A
        Dim i As Intent
        i.Initialize("android.intent.action.GET_CONTENT", "")
        i.AddCategory("android.intent.category.OPENABLE")
        i.PutExtra("android.intent.extra.ALLOW_MULTIPLE", True)
        i.SetType("image/*")
        StartActivityForResult(i)
    #Else If B4i
        ph_return_images.Initialize
        Dim nativeObjectMe As NativeObject = Me
        nativeObjectMe.RunMethod("showPicker:", Array(B4XPages.GetNativeParent(Me)))
    #End If
End Sub
 
Last edited:
Top