bryankeller / BLKFlexibleHeightBar

Create condensing header bars like those seen in the Facebook, Square Cash, and Safari iOS apps.
MIT License
3.04k stars 338 forks source link

Not working with Swift #42

Open anwol004 opened 9 years ago

anwol004 commented 9 years ago

Hello i try to use this repo but this is not working in swift.

Gives an problem with the tableview.delegate downcast, has anyone solution for this problem?

Greetz

phausero commented 9 years ago

Yeah, I think all you have to do is extending BLKDelegateSplitter with the protocol you want to use. In your case UITableViewDelegate.

trevisthomas commented 9 years ago

I'm pretty new to Swift and iOS and I spent a lot of hours to come to the conclusion that the break was with this class. Modifying the BLKDelegateSplitter class to conform to the UITableViewDelegate protocol fixed it for me. I have the demo running now with a Swift based view controller.

rafalkitta commented 9 years ago

@trevisthomas could you show your BLKDelegateSplitter conformation to the UITableViewDelegate?

trevisthomas commented 9 years ago

Just edit the BLKDelegateSplitter.h file. Replace the @implementation declaration at line 29 with:

@interface BLKDelegateSplitter : NSObject <NSObject, UITableViewDelegate>
rafalkitta commented 9 years ago

Thank you for your response. You're right. Also @rabzu Demo in Swift pull request https://github.com/bryankeller/BLKFlexibleHeightBar/pull/20 was very helpful.

extension BLKDelegateSplitter: UICollectionViewDelegate {
}
tgyhlsb commented 9 years ago

Hi rafalkitta,

I tried with your extension so I don't get the compiler error. But at run time, the BLKDelegateSplitter does not forward the calls to any of its sub-delegates.

Have you modify anything else to make it work ? I use Swift 2.0

tgyhlsb commented 9 years ago

It appeared I have to make a strong reference to the splitter because tableView.delegate is weak. Why splitter was just deallocated by ARC...

Works perfectly now, great component !

harshilkotecha commented 6 years ago

This is working fine in swift 4 also add this extension to solve this issue this is work for me

extension BLKFlexibleHeightBarBehaviorDefiner :UITableViewDelegate{

}