Sephiroth87 / ODRefreshControl

A pull down to refresh control like the one in Apple's iOS6 Mail App
MIT License
2.15k stars 385 forks source link

Add support for custom frame #37

Closed XiaonuoGantan closed 11 years ago

XiaonuoGantan commented 11 years ago

Add a method -(id)initWithFrame:InScrollView: in ODRefreshControl to allow users of the class to provide a custom frame. Currently, ODRefreshControl is assuming that the parent UITableView has vertical UITableViewCells, which may not be the case in apps like Pulse-news, where the UITableViewCells are layed out horizontally on the UITableView. Add the aforementioned method to allow assigning custom frame for the control so that it can animate properly in a horizontal UITableView.

Sephiroth87 commented 11 years ago

Mhm, first of all, there's something very wrong, you should not use self before init...

Secondly, I don't see the point of this. I checked pulse, but it's a simple tableView and the control will work perfectly. Can you send me an example project where this is needed?

XiaonuoGantan commented 11 years ago

It's incorrect to use self before init. The method - (id)initInScrollView:activityIndicatorView: should be refactored into another method which calls another internal initializer to return self. That internal initializer should also be called by - (id)initWithFrame:InScrollView: to provide a custom frame.

An example project where this is needed is https://github.com/XiaonuoGantan/Felipe-Laso-HorizontalTableView-Demo-With-ODRefreshControl. Notice the file HorizontalTableCell_iPhone.m includes two ways to initialize a ODRefreshControl and the control cannot display properly when a custom frame is not provided.

Sephiroth87 commented 11 years ago

I now understand what you're trying to do, but it's such a special case that I don't like have to handle it here... (Also, that surely is an awkward way to implement an horizontal table, IMHO)...

Anyway, there's a much more simple solution to the problem: simply instantiate the refreshControl BEFORE applying the transform to the table view, and it'll work automagically ;)

XiaonuoGantan commented 11 years ago

You're absolutely correct! How come I never thought about this simple solution?!

Thank you for correcting my horrible code :)