1

I have horizontal UICollectionView with UIRefreshControl:

self.refreshControlMain = [[UIRefreshControl alloc] init];
//self.refreshControlMain.tintColor = [UIColor grayColor];
[self.refreshControlMain addTarget:self action:@selector(refershControlAction) forControlEvents:UIControlEventValueChanged];
[self.collectionViewMain addSubview:self.refreshControlMain];           
self.collectionViewMain.alwaysBounceVertical = YES;
self.collectionViewMain.pagingEnabled = YES;
self.collectionViewMain.showsHorizontalScrollIndicator = NO;
self.collectionViewMain.scrollEnabled = NO; 
//Because user can't scroll horizontally (he needs to press next button)

But this code doesn't work, because I can't drag it vertically. The only option I found is to set self.collectionViewMain.scrollEnabled = YES; (and in this case I can drag it vertically, so that refresh control appears), but in this case user is able to scroll horizontally (but user shouldn't be able to do that).

Is there any option to use refresh control in my situation?

update:

I don't need horisontal refresh control. I have horisontal collectionview, but I need vertical refresh control. if I put "self.collectionViewMain.scrollEnabled = YES" in my code, it works. but I need user not be able to scroll himself.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Paul T.
  • 4,938
  • 7
  • 45
  • 93

1 Answers1

0

UIRefreshControl does not support horizontal use natively.

There are various solutions whereby it has been extended for horizontal use.

Check out this link.

Or as per this answer 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!

Community
  • 1
  • 1
Woodstock
  • 22,184
  • 15
  • 80
  • 118
  • I don't need horisontal refresh control. I have horisontal collectionview, but I need vertical refresh control. if I put "self.collectionViewMain.scrollEnabled = YES" in my code, it works. but I need user not be able to scroll himself. pls see my update – Paul T. May 01 '14 at 20:04