Permalink
Browse files

Add support for custom frame

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.
  • Loading branch information...
1 parent c08ae5b commit 46f3844700f4b16b99a383f8092c5d12a35661d9 Xiaonuo Gantan committed Oct 5, 2012
Showing with 13 additions and 1 deletion.
  1. +3 −0 ODRefreshControl/ODRefreshControl.h
  2. +10 −1 ODRefreshControl/ODRefreshControl.m
@@ -30,6 +30,9 @@
- (id)initInScrollView:(UIScrollView *)scrollView;
+// use custom frame
+- (id)initWithFrame:(CGRect)frame InScrollView:(UIScrollView *)scrollView;
+
// use custom activity indicator
- (id)initInScrollView:(UIScrollView *)scrollView activityIndicatorView:(UIView *)activity;
@@ -51,9 +51,18 @@ - (id)initInScrollView:(UIScrollView *)scrollView {
return [self initInScrollView:scrollView activityIndicatorView:nil];
}
+- (id)initWithFrame:(CGRect)frame InScrollView:(UIScrollView *)scrollView {
+ self = [super initWithFrame:frame];
+ return [self initInScrollView:scrollView activityIndicatorView:nil];
+}
+
- (id)initInScrollView:(UIScrollView *)scrollView activityIndicatorView:(UIView *)activity
{
- self = [super initWithFrame:CGRectMake(0, -(kTotalViewHeight + scrollView.contentInset.top), scrollView.frame.size.width, kTotalViewHeight)];
+ if (CGRectEqualToRect(self.frame, CGRectZero)) {
+ CGRect sRect = CGRectMake(0, -(kTotalViewHeight + scrollView.contentInset.top),
+ scrollView.frame.size.width, kTotalViewHeight);
+ self = [super initWithFrame:sRect];
+ }
if (self) {
self.scrollView = scrollView;

0 comments on commit 46f3844

Please sign in to comment.