2

How do I go and implement a UIRefreshControl which would get refreshed when pulled from left or right side??

Is it possible with the standard UIRefreshControl? Or is there any API to create this effect? I have been searching a lot to get some lead on this but I am not able to find anything.

All I could find is this answer on SO, but it is written in C# which I am not much familiar with.

Community
  • 1
  • 1
mayuur
  • 4,736
  • 4
  • 30
  • 65

2 Answers2

1

You could use a UITableViewController that is rotated 90 degrees.

Add [self.view setTransform:CGAffineTransformMakeRotation(-M_PI / 2)]; in the UITableViewController class during setup.

Example using UITableView (and not UITableViewController):

table_ = [[UITableView alloc] initWithFrame:self.bounds];
[table_ setDelegate:self];
[table_ setDataSource:self];
[table_ registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
[table_ setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];

UIRefreshControl *ctrl = [[UIRefreshControl alloc] init];
[ctrl setBackgroundColor:[UIColor yellowColor]];
[table_ addSubview:ctrl];

[self addSubview:table_];

Make sure to remember to rotate the content back again in the opposite direction!

LK__
  • 6,515
  • 5
  • 34
  • 53
  • Actually I would be using the UIRefreshControl without tableview. something like this http://stackoverflow.com/a/12502450/593336 Also, I am curious that would just rotating it won't effect any effects or images of UIRefreshControl? – mayuur Mar 30 '13 at 22:37
  • You can add the UIRefreshControl as a subview of a UITableView (as in the linked post) but not to a regular UIView. If adding to a UITableView and not to a UITableViewController, then simply perform the tranformation on the UITableView – LK__ Mar 30 '13 at 22:45
  • Ok. Actually I am looking for a Pull-to-refresh functionality for UIScrollView, but from left side, not from top. Rotating the tableview/scrollview would also rotate the items inside it, which I won't want as I already have a horizontal UIScrollView – mayuur Mar 30 '13 at 22:49
  • This is what I meant by needing to rotate the content back again. You have to set the transform of the cell to (M_PI / 2) - or make your own UITableViewCell derived class where you do this. – LK__ Mar 31 '13 at 04:21
-1

There are no default refreshcontrol for this. You have to create custom refreshcontrol to get this behaviour.

user
  • 11
  • 2