printdotio / printio-ios-sdk

SDK that enables the printing of any photo, from any source, onto any product!
Other
20 stars 11 forks source link

buttonIconPath doesn't render image #526

Closed rherubin closed 7 years ago

rherubin commented 7 years ago

Ok, so here's an example of my own photo source that inherits from PIODefaultPhotoSource:

class AppCustomPhotoSource: PIODefaultPhotoSource {
    override func title() -> String! {
        return "Custom App"
    }

    override func buttonIconPath() -> String! {
        let imagePath = "My icon name in xcassets"

        if let _ = UIImage(named: imagePath) {
            return imagePath
        }

        guard let bundleImagePath = Bundle.main.path(forResource: "icon outside of xcassets", ofType: "pdf") else {
            return ""
        }

        return bundleImagePath
    }

    override func isAuthed() -> Bool {
        return true
    }

    override func requestConcreteItems(_ items: NSMutableArray!,
                                       for item: PIOPhotoSourceItem!,
                                       inScope currentScope: PIOPhotoSourceItem!,
                                       page: UInt,
                                       count: UInt,
                                       withCompletionHandler completionHandler: PIOItemsCompletionHandler!,
                                       errorHandler: PIOPhotoSourceErrorHandler!)
    {
        print("no-op in this instance")
    }
}

In the buttonIconPath fund above, I give the two examples of how I've been trying to get this code to work without any success (once thinking it just required the "named" property of a UIImage and the other getting a bundle path for resource).

Any advice would be greatly appreciated!

P.S. I've added PrintIO SDK via cocoapods