Implement a horizontal UIRefreshControl

爷,独闯天下 提交于 2019-12-09 21:42:27

问题


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.


回答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!




回答2:


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



来源:https://stackoverflow.com/questions/15723770/implement-a-horizontal-uirefreshcontrol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!