luispadron / UIEmptyState

An empty state control to give visually appealing context when building iOS applications.
MIT License
178 stars 34 forks source link

Detail message not shown due to typo. #6

Closed vitobellini closed 7 years ago

vitobellini commented 7 years ago

emptyStateTitle works fine, but not the detailed one (with or without image)

emptyStateDetailMessage is never shown

    var emptyStateTitle: NSAttributedString {
        let attrs = [NSForegroundColorAttributeName: UIColor(red: 0.882, green: 0.890, blue: 0.859, alpha: 1.00),
                     NSFontAttributeName: UIFont.systemFont(ofSize: 22)]
        return NSAttributedString(string: "Main message...", attributes: attrs)
    }

    var emptyStateDetailMessage: NSAttributedString {
        let attrs = [NSForegroundColorAttributeName: UIColor.black,
                     NSFontAttributeName: UIFont.systemFont(ofSize: 18)]
        return NSAttributedString(string: "Detailed message...", attributes: attrs)
    }
luispadron commented 7 years ago

I'm going to need more information than that. What version are you using and if you could upload an example of the app that would be best.

vitobellini commented 7 years ago

full code here https://pastebin.com/EXjDzTdD

iOS 11 on iPhone 6 Plus (actual device)

luispadron commented 7 years ago

You have a typo in your type. emptyStateDetailMessage is optional, since you declared it as non-optional UIEmptstate used the default implementation found here which returns a nil message thus why you're not seeing your detail message.

You don't get a compiler warning for this since you are technically fully conformed to UIEmpstateDataSource but your emptyStateDetailMessage getter will never be called. This is a bit of an issue with Swift itself since it doesn't warn you for obvious typos such as this one. Make emptyStateDetailMessage optional and your code will work just fine!

Also, please read the docs as it has all the correct names for methods/variables.