B4i Library Photo Browser Library

Discussion in 'iOS Libraries' started by Haris Hafeez, May 31, 2015.

  1. Haris Hafeez

    Haris Hafeez Active Member Licensed User

    Hey Everybody,

    I am pleased to publish a library that will allow you to show an image/photo browser.

    All you have to do in your code is to use the photo browser object, pass it the list of urls(can be local or remote) and call the Show method, passing in your NavControl object. The photo browser takes care of downloading the images, caching, swipe to view next/previous, zooming etc. It also has a built-in action button that lets you share the images.

    As much as I'd like to take credit for this, the real credit should to Michael Waterfall, the author of the wonderful MWPhotoBrowser library. I just sweated over creating the B4i wrapper :)

    I'm copying a link to the library zip as it's a little over the limit (800kb) to attach here. The two library archives(.a files) and the header file(.h file) you need to copy to your local mac builder's Libs directory. If you're using hosted builder, you will not be able to use it unless B4i overlord(Erel) takes the library source from me and decides to add it to base.

    You also need to copy the .xml file to your B4i installations libraries directory.

    A sample project is also attached here.

    The library as it stands is fairly basic. It doesn't currently support any callbacks(events) but I will look into adding some as and when required.

    Link:

    https://drive.google.com/file/d/0ByDFbtVDbyXZeEM4SkdiYXkzVlU/view?usp=sharing

    Have fun!

    Harris.
     

    Attached Files:

    Erel likes this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    Thank you for sharing. I've uploaded it to the builders.
     
  3. narek adonts

    narek adonts Well-Known Member Licensed User

    got the following error

    Code:
    duplicate symbol _OBJC_CLASS_$_MBBarProgressView in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_CLASS_$_MBProgressHUD 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_CLASS_$_MBRoundProgressView 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBBarProgressView._lineColor 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBBarProgressView._progress 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBBarProgressView._progressColor 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBBarProgressView._progressRemainingColor 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.animationType 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.color 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.completionBlock 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.customView 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.delegate 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.detailsLabel 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.detailsLabelFont 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.detailsLabelText 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.dimBackground 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.graceTime 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.graceTimer 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.indicator 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.isFinished 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.label 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.labelFont 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.labelText 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.margin 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.methodForExecution 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.minShowTime 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.minShowTimer 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.minSize 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.mode 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.objectForExecution 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.opacity 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.progress 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.removeFromSuperViewOnHide 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.rotationTransform 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.showStarted 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.size 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.square 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.targetForExecution 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.taskInProgress 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.useAnimation 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.xOffset 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBProgressHUD.yOffset 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBRoundProgressView._annular 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBRoundProgressView._backgroundTintColor 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBRoundProgressView._progress 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_IVAR_$_MBRoundProgressView._progressTintColor 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_METACLASS_$_MBBarProgressView 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_METACLASS_$_MBProgressHUD 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    duplicate symbol _OBJC_METACLASS_$_MBRoundProgressView 
    in:
        ../../Libs/libMWPhotoBrowser.a(MBProgressHUD.o)
        ../../Libs/libiDebug.a(MBProgressHUD.o)
    ld: 
    49 duplicate symbols for architecture arm64
    clang: error: linker command failed with 
    exit code 1 (use -v to see invocation)
     
  4. Haris Hafeez

    Haris Hafeez Active Member Licensed User

    Are you using local builder or hosted?
     
  5. narek adonts

    narek adonts Well-Known Member Licensed User

    Hosted. Erel wrote that he has upload the lib to the builder.
     
  6. Haris Hafeez

    Haris Hafeez Active Member Licensed User

    I came across this issue on my local builder but fixed it before releasing the library files.
    I will look into it when I get back home this evening and revert.
     
  7. Haris Hafeez

    Haris Hafeez Active Member Licensed User

    Hey guys,

    So I just looked into it and we've got an interesting issue to resolve. If you build the sample app in release mode (or your app) with the photo browser library, you will not face any issues. But if you build it in debug mode, you will get the error you reported.

    The issue is because when I was developing the B4i wrapper for the MWPhotoBrowser library, I realized that there is a conflict with an internal library of B4i, called iDebug. iDebug relies on MBProgressHUD to present the progress dialog while we are debugging an app. This class is also used internally by the MWPhotoBrowser library to present progress dialogs. So when I was building my app in debug, I was getting the above reported conflict. In order to resolve the conflict at debug time, I compiled the MWPhotoBrowser library without the header file that containes MBProgressHUD related classes. This resolved the issue for debug.
    The story didn't end there unfortunately. When I compiled for release, I got an error where the compiler complained that the linked library MWPhotoBrowser did not have the said interfaces declared. So to fix this I added the MBProgressHUD.h back to the MWPhotoBrowser library, and the release worked perfectly.

    The short story is that it seems quite complex to resolve this issue. This is because when we compile for release, classes in iDebug.a do not end up in our apps(this is what I believe happens) so the linker cannot find the MBProgressHUD classes which in debug mode were provided by iDebug.a library. So what I have done myself now is to have two versions of the MWPhotoBrowser library(.a files): one that I use for debug and the other that I use for release.

    I understand that this solution sucks as far as technical grace goes. Its ugly and will not work with hosted builders. I have a few solutions in mind and am open to discussing them and working on them with you guys, :

    1. Build a debug version of the library that you will use in your project while debugging but switch to the release version when you want to release the app. So you will have an HHPhotoBrowser-Debug and HHPhotoBrowser-Release available in your B4i IDE and you use the one depending on your deployment cycle. An ugly solution in my opinion but hey, we're dealing with a dog of a situation here :)
    2. Use a local mac builder and swap/replace the debug version of the libMWPhotoBrowser.a file depending on whether you are compiling for debug. So in your mac builder's lib folder, you will have two libMWPhotoBrowser.a files, with one named -debug.a and the other just named libMWPhotoBrowser.a. Again an ugly option.
    3. I will try to work on creating a wrapper for another photo browser library but this photo browser in my opinion is the best and the most widely used in my research.
    4. The final I can think of is for asking Erel to help us out with this :) Perhaps he can find a way to conditionally load the MBProgressHUD related classes from the iDebug.a if required? Not sure.
    I am attaching a version of libMWPhotoBrowser.a Please rename it so you remove the -DEBUG from the name and use it in your local mac builder when you build for debug. Later, when you want to buld for release, you should copy the original libMWPhotoBrowser.a and save the debug version by renaming it again -DEBUG. Yuck....

    Let me know how you guys get along and let's try to find a solution.

    Link to library that you can use in debug:

    https://drive.google.com/file/d/0ByDFbtVDbyXZamRta3hXd2thcW8/view?usp=sharing

    Best,
    Harris.
     
    Last edited: Jun 1, 2015
  8. little3399

    little3399 Active Member Licensed User

    Hi, Harris
    Dose this Library can support the loca folder files which in File.DirAssets ? TKS!
     
  9. Haris Hafeez

    Haris Hafeez Active Member Licensed User

    Yes it does. All you need is a list of file:// urls which you can pass to the photo browser object.
     
  10. little3399

    little3399 Active Member Licensed User

    Hi, Haris
    I using file://urls , but It seem not to work ? here was my code file ... and your any suggestion ?
     

    Attached Files:

  11. Haris Hafeez

    Haris Hafeez Active Member Licensed User

    I'm afraid your B4I code isn't correct. You're not using the File object properly.
    This line: out = File.OpenOutput(File.DirDocuments&DirName, FileName, False) in SavePictureToFile is not correct. Basically, you should do something like this:
    Code:
    out = File.OpenOutput(File.DirDocuments, FileName, False)
    I recommend reading up a bit on using the File object :)
     
  12. little3399

    little3399 Active Member Licensed User

    Hi, Haris

    Thank for you suggestion, but my photo is save in these directory structure... so my b4i code should be correct ...
    So I'm not sure whether photos library browser can support the directory structure? Tks!
     

    Attached Files:

  13. Haris Hafeez

    Haris Hafeez Active Member Licensed User

    I am not sure I follow. The app crashed when I tested it at the line where it tries to open the output stream.

    Anyways, back to your main question. The library currently does have some issues with the file:// url. This is related to B4i library development and I am currently working on finding the best way forward for this and other libraries that depend on local files.
    I haven't uploaded an updated library because I want to work on the recommended way for working on a File that works both in DEBUG and RELEASE. If you're using local builder, I may be able to send you an updated library.

    To read more on the subject, please refer to this link.
     
  14. little3399

    little3399 Active Member Licensed User

    I had been setup the debug library of PhotoBrowser ... and update your update lib on #7 post ...

    upload_2015-6-23_9-50-25.png
     
    Last edited: Jun 23, 2015
  15. Haris Hafeez

    Haris Hafeez Active Member Licensed User

    I will update the library here to help with the local files issue (hopefully tonight) when I get back from (paid) work :)
     
  16. Haris Hafeez

    Haris Hafeez Active Member Licensed User

    I have updated the library so it now works well with local image assets. Note that you will have to pass in Bitmap objects if you want to show local images.

    The updated library files can be downloaded here.

    Using local files:
    Code:
    Sub ShowImage
        
    Dim l As List: l.Initialize
        
    Dim b As Bitmap = LoadBitmap(File.DirAssets, "audio_icon_default_gd.png")
        l.Add(b)
        b = 
    LoadBitmap(File.DirAssets, "audio_icon_default_od.png")
        l.Add(b)
        b = 
    LoadBitmap(File.DirAssets, "audio_icon_default_db.png")
        l.Add(b)
       
        
    Dim pv As HHPhotoBrowser
        pv.Initialize2(
    "pv", l)
        pv.SetCurrentPhotoIndex(
    1'start from the second photo in the list
        pv.Show(NavControl)
    End Sub
     
  17. little3399

    little3399 Active Member Licensed User

    Hi, Haris
    Thanks for your good library ... but I want to adding some function about this library ,
    1. Does can add the photo describe
    2. return the CurrentPhotIndex ...

    Tks!
     

    Attached Files:

  18. Haris Hafeez

    Haris Hafeez Active Member Licensed User

    I can certainly do it :) Only that finding a bit of spare time is getting a bit challenging. I will try to find some time tonight (or this week) and update.

    Note that choosing a photo will require you to implement a custom action. I will change the library (at least that's the plan) to raise an event when the action button is clicked. You will have to implement the action yourself.
     
  19. little3399

    little3399 Active Member Licensed User

    Hi,Haris

    The library seem no support the XCODE 7.1 ?
     
  20. imbault

    imbault Well-Known Member Licensed User

    Hi @Haris Hafeez, can you please, compile your lib under xCode 7.1.

    It would be nice

    Thx

    Patrick
     
  21. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    Hello Haris,

    Can we enumerate all photo albums with this library?

    Or move some phote from Camera Roll to specific Album?

    Thanks

    Alberto Iglesias
     
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