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

Cannot form weak reference to instance of class MediaBrowser. #63

Open
cylak opened this issue Nov 16, 2018 · 3 comments
Open

Cannot form weak reference to instance of class MediaBrowser. #63

cylak opened this issue Nov 16, 2018 · 3 comments

Comments

@cylak
Copy link

cylak commented Nov 16, 2018

Hi,
Thanks for your great library!
I want to show multiplePhotoGrid() in the first app view controller. But i get this error:

Cannot form weak reference to instance (0x7faf25043a00) of class MediaBrowser.MediaBrowser. It is possible that this object was over-released, or is in the process of deallocation.

And xcode point to line 64 in the MediaBrowser.swift file.

Thanks

AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    
    window = UIWindow(frame: UIScreen.main.bounds)
    window?.makeKeyAndVisible()
    let mainVC = ViewController()
    window?.rootViewController = mainVC
    
    return true
}

ViewController.swift

class ViewController: UIViewController, MediaBrowserDelegate {
    
    var selections = [Bool]()
    var mediaArray = [Media]()
    var thumbs = [Media]()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let displayActionButton = true
        let displaySelectionButtons = false
        let displayMediaNavigationArrows = true
        let enableGrid = true
        let startOnGrid = false
        let autoPlayOnAppear = false
        
        mediaArray = DemoData.multiplePhotoGrid()
        thumbs = DemoData.multiplePhotoGrid()
        
        let browser = MediaBrowser(delegate: self)
        browser.displayActionButton = displayActionButton
        browser.displayMediaNavigationArrows = displayMediaNavigationArrows
        browser.displaySelectionButtons = displaySelectionButtons
        browser.alwaysShowControls = displaySelectionButtons
        browser.zoomPhotosToFill = true
        browser.enableGrid = enableGrid
        browser.startOnGrid = startOnGrid
        browser.enableSwipeToDismiss = true
        browser.autoPlayOnAppear = autoPlayOnAppear
        browser.cachingImageCount = 2
        browser.setCurrentIndex(at: 1)
        
        navigationController?.pushViewController(browser, animated: true)
        
    }
    
    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")
    }

}
@joshid
Copy link

joshid commented Feb 6, 2019

Same error here. Any tips for workaround this?

@nerzh
Copy link

nerzh commented Feb 21, 2020

Cool library, but No

@voronoff2803
Copy link

Same error.

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

4 participants