Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Badges don't display in view-based cells loaded from a storyboard #53

Open
graemesi opened this issue Jul 20, 2015 · 4 comments
Open

Badges don't display in view-based cells loaded from a storyboard #53

graemesi opened this issue Jul 20, 2015 · 4 comments

Comments

@graemesi
Copy link

For view-based mode, OS X 10.10.3, running Xcode 6.4:

When a PXSourceListTableCellView is designed inside a storyboard, the badge view is never displayed. The same behaviour is seen if loaded from a xib and the "Prefer coder" option is checked in Interface Builder. You can see this behaviour by checking the "Prefer coder" option for the MainMenu.xib in the ViewBasedSourceList demo project.

I believe this is because the underlying PXSourceListBadgeCell is never initialised due to the way the storyboard or nib is loaded via the initWithCoder: path.

@Miirek
Copy link

Miirek commented Sep 14, 2015

Hi, look at this.
https://mikeash.com/pyblog/custom-nscells-done-right.html

BTW thanks for filling this issue, I'm not that good in Cocoa and its about a week ago I've stubled upon this issue. Not knowing what caused it was making me mad :D

@tofutim
Copy link

tofutim commented Jun 28, 2016

I'm still not quite sure how to use PXSourceList correctly. Do we have to manually generate the BadgeView in IB and size it? Here is my current process:

  1. Drag into my MainView a SourceList
  2. Change the class into PXSourceList or a class derived from PXSourceLIst
  3. Change the TableCellView that is "DataCell" to "MainCell"
  4. Change both HeaderCell and MainCell to PXSourceListTableCellView

At this point everything still looks the same as before, and there is no BadgeView in MainCell, not even an outlet. Am I missing something here? @Miirek, did you end up doing that subclass thing in the custom-nscells-done-right link? Should I be manually creating the Badgeview, and hooking up the outlet?

@HamGuy
Copy link

HamGuy commented Jan 10, 2017

same issue with subclass the PXSourceListTableCellView

    func configCell(tag: Tag){
        textField?.stringValue = tag.name
        imageView?.image =  NSImage.fontAwesomeIconWithName(.Tag, textColor: .lightGray, size: CGSize(width: 40, height: 40), backgroundColor: .clear)
        badgeView.badgeValue = UInt(tag.starsCount)
        badgeView.isHidden = tag.likeCount == 0
        badgeView.textColor = .red
        badgeView.backgroundColor = .blue
    }

@kelvinjjwong
Copy link

I just found a tricky approach that works fine for me (Swift 4, storyboard)

  1. Create a subclass of PXSourceListTableCellView, such as LCSourceListTableCellView.
  2. Add a label "badge" with @IBOutlet into the new cell view in order to replace the badgeView
  3. In Interface Builder, change the class of table cell view of DataCell from PXSourceListTableCellView to LCSourceListTableCellView
  4. In Interface Builder, connect the "badge" outlet to the table cell view above, just as what we did for PXSourceListTableCellView
  5. In the func sourceList(_ aSourceList:PXSourceList!, viewForItem item: Any!) , change the type of cellView to LCSourceListTableCellView for DataCell, set the numbers into the title property of the label "badge" instead of the old "badgeView"
  6. Override layout() in LCSourceListTableCellView, set the colors and corner radius for the label as what you like

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants