UITableView自定义拉动刷新视图不会显示

时间:2015-07-10 17:18:51

标签: ios objective-c uitableview pull-to-refresh

我有自定义拉动刷新的以下代码。

CGFloat customRefreshControlHeight = 50.0f;
CGFloat customRefreshControlWidth = 320.0f;
CGRect customRefreshControlFrame = CGRectMake(0.0f,
                                              -customRefreshControlHeight,
                                              customRefreshControlWidth,
                                              customRefreshControlHeight);

TestRefreshView *refreshView = [[TestRefreshView alloc] init];
refreshView.frame = customRefreshControlFrame;
self.testRefreshView = refreshView;

[self.tableView addSubview: self.testRefreshView];

然而,当我拉下桌子时,这个视图并没有显示出来。还有什么我需要设置的,我失踪了吗?

1 个答案:

答案 0 :(得分:1)

这是我在UIView中使用自定义UIrefreshController的工作示例:

self.refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl.frame = CGRectMake(x,
                                   y,
                                   self.refreshControl.bounds.size.width,
                                   self.refreshControl.bounds.size.height);

self.animIndView = [[AnimatorIndicatorView alloc] initWithFrame:self.refreshControl.frame];


[self.refreshControl addTarget:controller action:@selector(refrechLocation:) forControlEvents:UIControlEventValueChanged];
[self.refreshControl setTintColor:[UIColor clearColor]];

[controller.refreshControl addSubview:self.animIndView];

[self.tableView addSubview:self.refreshControl];