🏞 A simple iOS photo and video browser with optional grid view, captions and selections written in Swift5.0

Overview

title

License: MIT Swift iOS 8.1+ travis CocoaPods CocoaDocs Carthage ReadMe-KR

Introduction

🏞 MediaBrowser can display one or more images or videos by providing either UIImage objects, PHAsset objects, or URLs to library assets, web images/videos or local files. MediaBrowser handles the downloading and caching of photos from the web seamlessly. Photos can be zoomed and panned, and optional (customisable) captions can be displayed. This can also be used to allow the user to select one or more photos using either the grid or main image view.

Also, MediaBrowser use latest SDWebImage version for caching, motivated by MWPhotoBrowser

Single Photo Multiple Photos And Video
SinglePhoto MultiplePhotosAndVideo
Multiple Photo Grid Multiple Photo Selection
MultiplePhotoGrid PhotoSelection
Web Photos Web Photos Grid
WebPhotos WebPhotoGrid

Requirements

MediaBrowser is written in Swift 5.0 Compatible with iOS 8.0+

Usage

Basic

Get MediaBrowser and set MediaBrowserDelegate

let browser = MediaBrowser(delegate: self)
self.navigationController?.pushViewController(browser, animated: true)

//MediaBrowserDelegate
func numberOfMedia(in mediaBrowser: MediaBrowser) -> Int {
  return mediaArray.count
}
    
func media(for mediaBrowser: MediaBrowser, at index: Int) -> Media {
  if index < mediaArray.count {
    return mediaArray[index]
  }
  return DemoData.localMediaPhoto(imageName: "MotionBookIcon", caption: "Photo at index is Wrong")
}

Advanced

CocoaDocs is the best place to start!

You can also see all usage in demo project.

Property Type
navigationBarTranslucent Bool
navigationBarTextColor UIColor
navigationBarTintColor UIColor
statusBarStyle UIStatusBarStyle
toolbarTextColor UIColor
toolbarBarTintColor UIColor
toolbarBackgroundColor UIColor
hasBelongedToViewController Bool
isVCBasedStatusBarAppearance Bool
statusBarShouldBeHidden Bool
displayActionButton Bool
leaveStatusBarAlone Bool
performingLayout Bool
rotating Bool
viewIsActive Bool
didSavePreviousStateOfNavBar Bool
skipNextPagingScrollViewPositioning Bool
viewHasAppearedInitially Bool
currentGridContentOffset CGPoint
zoomPhotosToFill Bool
displayMediaNavigationArrows Bool
displaySelectionButtons Bool
alwaysShowControls Bool
enableGrid Bool
enableSwipeToDismiss Bool
startOnGrid Bool
autoPlayOnAppear Bool
hideControlsOnStartup Bool
delayToHideElements TimeInterval
captionAlpha CGFloat
toolbarAlpha CGFloat
loadingIndicatorInnerRingColor UIColor
loadingIndicatorOuterRingColor UIColor
loadingIndicatorInnerRingWidth CGFloat
loadingIndicatorOuterRingWidth CGFloat
loadingIndicatorFont UIFont
loadingIndicatorFontColor UIColor
loadingIndicatorShouldShowValueText Bool
mediaSelectedOnIcon UIImage?
mediaSelectedOffIcon UIImage?
mediaSelectedGridOnIcon UIImage?
mediaSelectedGridOffIcon UIImage?
preCachingEnabled Bool
cachingImageCount Int
placeholderImage (image: UIImage, isAppliedForAll: Bool)?
Method Explanation
setCurrentIndex(at index: Int) Set current indexPath when start. Also, set first before preCachingEnabled
Delegate Explanation
func numberOfMedia(in mediaBrowser: MediaBrowser) -> Int Required protocol to use MediaBrowser. return media count
func media(for mediaBrowser: MediaBrowser, at index: Int) -> Media Required protocol to use MediaBrowser. return media
func mediaBrowserDidFinishModalPresentation(mediaBrowser: MediaBrowser) Optional protocol to mediaBrowser Did Finish Modal Presentation
func thumbnail(for mediaBrowser: MediaBrowser, at index: Int) -> Media Optional protocol to show thumbnail. return media. Recommand small size
func captionView(for mediaBrowser: MediaBrowser, at index: Int) -> MediaCaptionView? Optional protocol to show captionView. return MediaCaptionView.
func didDisplayMedia(at index: Int, in mediaBrowser: MediaBrowser) Optional protocol when need callback
func actionButtonPressed(at photoIndex: Int, in mediaBrowser: MediaBrowser) Optional protocol when need callback about action button
func isMediaSelected(at index: Int, in mediaBrowser: MediaBrowser) -> Bool Optional protocol when need callback about isMediaSelected
func mediaDid(selected: Bool, at index: Int, in mediaBrowser: MediaBrowser) Optional protocol when need callback about media selection
func title(for mediaBrowser: MediaBrowser, at index: Int) -> String? Optional protocol for title

Installation

Cocoapods

pod 'MediaBrowser'

Carthage

github "younatics/MediaBrowser"

References

Please tell me or make pull request if you use this library in your application :)

Updates

See CHANGELOG for details

Author

younatics Twitter

License

MediaBrowser is available under the MIT license. See the LICENSE file for more info.

Comments
  • Black bars flash for a second when pushing back.

    Black bars flash for a second when pushing back.

    There seems to be a weird bug - that does not affect MediaBrowser only - in which a black bar shows up for a second when popping back from the MediaBrowser view controller. You can observe said behavior on the gifs provided by the project itself.

    Black Bars

    You can see the image show up for a second when the browser pushes back. At first I didn't think it was so bad, but it can be bit surprising when you actually see the bars happening on your device.

    Here's a still shot of the black bar:

    Black bar

    MWPhotoBrowser also has this problem.

    opened by AndyIbanez 6
  • Issue with Selection and Action button together

    Issue with Selection and Action button together

    Hi younatics,

    thanks for a great media browser, I came here from MWPhotoBrowser, which is not maintained anymore, and I like your project.

    I need the selection feature and the action button together in use case "Photo selection grid". If I do this, the action button moves to the upper right corner and hides the "Done" button and its function. I did a quick fix for this, commenting this line out in updateNavigation(): self.navigationItem.rightBarButtonItem = ab

    which fixes the issue. Could you please maybe add an extra option / public setter for this case, or do you accept a pull request for this? My fix workes for me, but want to stay in sync with this repo for further updates.


    Also, another minor issue: If I tap a photo in the grid, the blue selection image is briefly show all though the photo was not selected, while the grid view is animating out. I debugged this and found out it seems to happen below this line, in the animation: // Animate, hide grid and show paging scroll view

    Can you think of a way to fix this?

    Thanks,

    opened by TomMajor 3
  • Carthage compatibility

    Carthage compatibility

    Has anyone got this to work using Carthage?

    There is no Cartfile in the project for SDWebImage and UICircularProgressRing. Adding these frameworks to the project's Cartfile (as documented) results in build errors like these:

    /Users/josvanvelzen/projects/socialschools-ios/Carthage/Checkouts/MediaBrowser/MediaBrowser/MediaZoomingScrollView.swift:10:8: error: no such module 'UICircularProgressRing'
    import UICircularProgressRing
           ^
    

    also, in the build phases there is a hard dependency to CocoaPods

    PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/josvanvelzen/Library/Caches/org.carthage.CarthageKit/DerivedData/9.2_9C40b/MediaBrowser/2.0.6/Build/Intermediates.noindex/ArchiveIntermediates/MediaBrowser/IntermediateBuildFilesPath/MediaBrowser.build/Release-iphoneos/MediaBrowser.build/Script-0C26AE7EAC3BB33AE3116C77.sh
        cd /Users/josvanvelzen/projects/socialschools-ios/Carthage/Checkouts/MediaBrowser
        /bin/sh -c /Users/josvanvelzen/Library/Caches/org.carthage.CarthageKit/DerivedData/9.2_9C40b/MediaBrowser/2.0.6/Build/Intermediates.noindex/ArchiveIntermediates/MediaBrowser/IntermediateBuildFilesPath/MediaBrowser.build/Release-iphoneos/MediaBrowser.build/Script-0C26AE7EAC3BB33AE3116C77.sh
    diff: /Podfile.lock: No such file or directory
    diff: /Manifest.lock: No such file or directory
    error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
    

    I am no expert in this, I added the Cartfile in the Carthage/Checkouts/MediaBrowser which does resolve the dependencies but I probably will still have to link to frameworks somehow.

    Has anyone got this to work using carthage only?

    opened by josjevv 3
  • Default implementation of actionButtonPressed is unreachable

    Default implementation of actionButtonPressed is unreachable

    In MediaBrowser.swift, line 2053

    if let d = delegate {
        d.actionButtonPressed(at: currentPageIndex, in: self, sender: sender)
        return
    }
    

    The function will always return here, since the delegate should be set. You should probably change the protocol extension to initiate the default behaviour (show UIActivityViewController) and just call it.

    opened by weakfl 3
  • Grid view image not loading

    Grid view image not loading

    I have to start mediabrowser with GridView and do this code Swift 5 Single image show but in grid view it's not showing

    let browser = MediaBrowser(delegate: self);
          
            browser.zoomPhotosToFill = true;
            browser.alwaysShowControls = true;
            browser.enableGrid = true;
            browser.startOnGrid = false;
    
            self.present(browser, animated: true) {
    
            }
    

    MediaBrowserDelegate

    func numberOfMedia(in mediaBrowser: MediaBrowser) -> Int {
            return self.arrGaller.count
        }
        
        func media(for mediaBrowser: MediaBrowser, at index: Int) -> Media {
            if index < arrGaller.count {
              return arrGaller[index]
            }
            return Media(image: UIImage(named: "logo")!)
        }
        
    

    Simulator Screen Shot - iPhone 6s - 2020-07-08 at 18 41 44 Simulator Screen Shot - iPhone 6s - 2020-07-08 at 18 41 50

    opened by ronak4567 2
  • Something about the license

    Something about the license

    Hello, Seungyoun Yi. Thanks for your project, I will use it in my close-source app. I have a question about the copyright about the image resources in your project. First of all, could I use the interface icons directly in my app or should I design and replace them all? Secondary, could I use those beautiful pictures in the demo?

    I don't know the source of those pictures and icons and care about their copyright. Wish you give me some advice and reply. Thank you.

    Also, I want to know if Mit license or other code license like Apache license still work for image resources?

    opened by ghost 2
  • Fix the toolbar positioning on iPhone X

    Fix the toolbar positioning on iPhone X

    Previouly, the toolbar would be cut off on the iPhone X as it would be too close to the curves and the home indicator.

    This commit updates the code that constructs the toolbar frame to use the safeAreaInset's bottom edge instead.

    Fixes: https://github.com/younatics/MediaBrowser/issues/35

    opened by mnvr 2
  • [request] Change Media access level to open

    [request] Change Media access level to open

    Would you mind changing the access level of the Media class to open?

    I'd like to use your library in a project with some legacy objective-c code. Writing a wrapper class was straight forward, however, I'd need to subclass Media to make it work.

    Of course I could fork, but would prefer no to...

    opened by weakfl 2
  • Added the sender object to the action protocol method, if delegate me…

    Added the sender object to the action protocol method, if delegate me…

    Added the sender object to the action protocol method, if delegate method is defined, call it then return. Show the action button in navbar when in grid selection mode.

    opened by Jack-Rouleau 2
  • Questions regarding using MediaBrowser with firebase

    Questions regarding using MediaBrowser with firebase

    Currently, my backend is supported by firebase, which is an cloud-hosted database that queries asynchronously. Currently it fetchs the list of picture urls from firebase. With the example provided in MediaBrowserSample, it seems like the number of pictures need to be predetermined before calling the browser or exception will be thrown. Is there any workaround on that? To display the pictures correctly while still fetching the data in the backend?

    opened by jpowang 2
  • Trying to Render Grid Gallery View in Swipe Tab View...

    Trying to Render Grid Gallery View in Swipe Tab View...

    screen shot 2017-09-20 at 3 31 05 pm

    I have tabs, as you can see in the screenshot, and i am trying to initiate the gallery in the tabs views without making it go full screen. I think i need help.

    screen shot 2017-09-20 at 3 32 51 pm Here is my source code for it

    PS: Need Help...?

    help wanted 
    opened by iunicron 2
  • Update target iOS to 13.0, fix compilation error

    Update target iOS to 13.0, fix compilation error

    • Update target to iOS 13.0
    • Fix issue with compilation error (fixes issue https://github.com/younatics/MediaBrowser/issues/85)
    • Remove some warnings of deprecated methods
    opened by hannadutkiewicz 0
  • swipe left right not working

    swipe left right not working

    I'm using grid, when I click on an image or video it opens but when I swipe left right I don't see the prev/next photo and the count on the navigation bar doesn't update. Is there something i've to do to enable it?

    opened by smoi 0
  • Problem while playing video in ios13

    Problem while playing video in ios13

    2019-12-19 12:07:55.317059+0530 WakeUppApp[2339:311223] [StatusBar] Hiding the status bar instance directly is not supported anymore, please update your app. 2019-12-19 12:07:55.317493+0530 WakeUppApp[2339:311223] [Playback] ❗️Error loading tracklist for queue feeder: Error Domain=MediaPlaybackCoreErrorDomain Code=0 "The identifierList changed before the data source finished loading." UserInfo={NSDebugDescription=The identifierList changed before the data source finished loading.}

    opened by PayalUmraliya 3
  • Camera Roll MediaBrowserDelegate

    Camera Roll MediaBrowserDelegate

    This is more of a wish list:

    • MediaBrowserDelegate.CameraRoll(n) is a shared instance that sources from the camera roll where n is the last n media according to date
    • live photo preview
    • configurable edit, trash, share icons with callbacks to the delegate for the action
    opened by alpdigitech 0
Releases(2.3.0)
Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift

SKPhotoBrowser Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift features Display one or more images by providi

keishi suzuki 2.4k Jan 6, 2023
Redesigned video player controls for iOS

Atlas Minimal stock video player replacement demo video Compiling Clone the repo, and make sure you have cephei and all that then just make clean pack

Chr1s 15 Feb 19, 2022
Creating a simple selectable tag view in SwiftUI is quite a challenge. here is a simple & elegant example of it.

SwiftUI TagView Creating a simple selectable tag view in SwiftUI is quite a challenge. here is a simple & elegant example of it. Usage: Just copy the

Ahmadreza 16 Dec 28, 2022
πŸ“Ή Framework to Play a Video in the Background of any UIView

SwiftVideoBackground is an easy to use Swift framework that provides the ability to play a video on any UIView. This provides a beautiful UI for login

Wilson Ding 334 Jan 7, 2023
An easy to use FAQ view for iOS written in Swift

FAQView An easy to use FAQ view for iOS written in Swift. This view is a subclass of UIView. Setup with CocoaPods If you are using CocoaPods add this

Mukesh Thawani 467 Dec 5, 2022
An easy to use FAQ view for iOS written in Swift

FAQView An easy to use FAQ view for iOS written in Swift. This view is a subclass of UIView. Setup with CocoaPods If you are using CocoaPods add this

Mukesh Thawani 466 Nov 9, 2021
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Jogendra 772 Dec 28, 2022
Confetti View lets you create a magnificent confetti view in your app

ConfettiView Confetti View lets you create a magnificent confetti view in your app. This was inspired by House Party app's login screen. Written in Sw

Or Ron 234 Nov 22, 2022
Cool Animated music indicator view written in Swift

Cool Animated music indicator view written in Swift. ESTMusicIndicator is an implementation of NAKPlaybackIndicatorView in Swift for iOS 8. ζœ¬δΊΊθ‘—δ½œηš„δΉ¦η±γ€ŠLa

Aufree 465 Nov 28, 2022
πŸ” Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!

YNSearch + Realm Support Updates See CHANGELOG for details Intoduction ?? Awesome search view, written in Swift 5.0, appears search view like Pinteres

Kyle Yi 1.2k Dec 17, 2022
πŸš€ Elegant Pager View fully written in pure SwiftUI.

PagerTabStripView Made with ❀️ by Xmartlabs team. XLPagerTabStrip for SwiftUI! Introduction PagerTabStripView is the first pager view built in pure Sw

xmartlabs 482 Jan 9, 2023
Show the weather effects onto view written in Swift4.2

URWeatherView What is this for? Showing some kinds of the weather effect, written in Swift4.2. This code style is the Protocol Oriented Programming. T

Urtaq 449 Dec 28, 2022
Simple and highly customizable iOS tag list view, in Swift.

TagListView Simple and highly customizable iOS tag list view, in Swift. Supports Storyboard, Auto Layout, and @IBDesignable. Usage The most convenient

Ela Workshop 2.5k Jan 5, 2023
A simple, customizable view for efficiently collecting country information in iOS apps.

CountryPickerView CountryPickerView is a simple, customizable view for selecting countries in iOS apps. You can clone/download the repository and run

Kizito Nwose 459 Dec 27, 2022
Swift based simple information view with pointed arrow.

InfoView View to show small text information blocks with arrow pointed to another view.In most cases it will be a button that was pressed. Example To

Anatoliy Voropay 60 Feb 4, 2022
πŸ“– A simple, highly informative page view controller

TL;DR UIPageViewController done properly. ⭐️ Features Simplified data source management & enhanced delegation. Dynamically insert & remove pages. Infi

UI At Six 1.8k Dec 24, 2022
TSnackBarView is a simple and flexible UI component fully written in Swift

TSnackBarView is a simple and flexible UI component fully written in Swift. TSnackBarView helps you to show snackbar easily with 3 styles: normal, successful and error

Nguyen Duc Thinh 3 Aug 22, 2022
TDetailBoxView is a simple and flexible UI component fully written in Swift

TDetailBoxView is a simple and flexible UI component fully written in Swift. TDetailBoxView is developed to help users quickly display the detail screen without having to develop from scratch.

Nguyen Duc Thinh 2 Aug 18, 2022
TSwitchLabel is a simple and flexible UI component fully written in Swift.

TSwitchLabel is a simple and flexible UI component fully written in Swift. TSwitchLabel is developed for you to easily use when you need to design a UI with Label and Switch in the fastest way without having to spend time on develop from scratch.

Nguyen Duc Thinh 2 Aug 18, 2022