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

delegate #2

Closed mriccasyncpoint closed 12 years ago

mriccasyncpoint commented 12 years ago

Hi, can you add the delegate for enable/disable it??!

Sephiroth87 commented 12 years ago

Hi, I'm not sure what you're asking for, a ODRefreshControlDelegate, which is not needed since it's a UIControl, or an enable property, which is already there, but since it's related to touch events, has no point?

If you want to disable it temporarily, you can simply remove the observer and hide it...

mmackh commented 12 years ago

Maybe I'm being dense here, but how would I go about let's say

  1. Fetching some data (asynchrones)
  2. Hide the RefreshControl?

I've looked at your demos, etc and I tried using selectors and everything. Could you implement a function that is

+(void) totallyEndRefresh {

}

and then call [refreshControl totallyEndRefresh] from anywhere (I'm also using SVProgressHUD in my project and it's just that)? I'm new to Obj C, so please let me know.

[

Sephiroth87 commented 12 years ago

Mhm, I'm not sure I understand what your trying to do, but this control is not similar to SVProgressHUD, because it's not used just to show there's a loading in progress, but to trigger the loading itself. It would make little sense to totally hide the control after the loading is done, since the user would not be able to trigger it anymore.

As for fetching and hiding, you do something like this:

I guess if you really wanted to hide it forever after the refresh, you could perform a selector / dispatch after 0.4 seconds, the duration of the hiding animation.

mmackh commented 12 years ago

I guess this is exactly the error I am trying to solve: http://cl.ly/image/31453Y031m2D

I cannot call the refreshControl from any other method

Sephiroth87 commented 12 years ago

That simply mean that you didn't save any reference to the refresh control anywhere. There are many ways you could do that, for example you can declare an instance variable in your @interface:

@interface MyViewController : UIViewController { ODRefreshControl *refreshControl; }

and use that variable instead of creating a new one when you alloc the control:

refreshControl = [[ODRefreshControl alloc] etc.....

Or, you could declare a property in your @interface

@property (nonatomic) ODRefreshControl *refreshControl;

synthesize it in you @implementation:

@implementation MyViewController @synthesize refreshControl

and use the property:

self.refreshControl = [[ODRefreshControl alloc] etc....

mmackh commented 12 years ago

Thank you very much for helping me out Fabio!