Iphone 如何向上添加pull tableview以刷新uitableview中的数据
我知道如何将拉刷新添加到视图控制器中。但是现在的情况是:我有一个Iphone 如何向上添加pull tableview以刷新uitableview中的数据,iphone,ios,uitableview,uiviewcontroller,Iphone,Ios,Uitableview,Uiviewcontroller,我知道如何将拉刷新添加到视图控制器中。但是现在的情况是:我有一个UIView&它包含一个UITableView,我想把tableview的最底部的表视图拉上去,重新加载它的数据 如何在此UITableView中添加拉入刷新,而不是其父视图的控制器。在视图中添加以下内容: UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selecto
UIView
&它包含一个UITableView
,我想把tableview的最底部的表视图拉上去,重新加载它的数据
如何在此
UITableView
中添加拉入刷新,而不是其父视图的控制器。在视图中添加以下内容:
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
[self.myTableView addSubview:refreshControl];
刷新
- (void)refresh:(id)sender
{
// do your refresh here and reload the tablview
}
它很简单:取一个
UIScrollView
,在它里面取UITableview
,放在UITableview
的底部,然后写Scrollview委托方法
#pragma mark -
#pragma mark - Scroll View Delegate Method
- (void) scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == scrollObj) {
CGFloat scrollPosition = scrollObj.contentSize.height - scrollObj.frame.size.height - scrollObj.contentOffset.y;
if (scrollPosition < 30)// you can set your value
{
if (!spinnerBottom.isAnimating) {
[spinnerBottom startAnimating];
[self YourPUllToRefreshMethod];
}
}
}
}
#pragma标记-
#pragma标记-滚动视图委托方法
-(无效)scrollViewDidScroll:(UIScrollView*)scrollView{
如果(scrollView==scrollObj){
CGFloat scrollPosition=scrollObj.contentSize.height-scrollObj.frame.size.height-scrollObj.contentOffset.y;
if(scrollPosition<30)//您可以设置您的值
{
如果(!Spinnerbotom.isAnimating){
[喷丝头底部启动激活];
[自我更新方法];
}
}
}
}
您是否试图在iOS 6中实现它?请查看此代码https://github.com/enormego/EGOTableViewPullRefresh
。您可以使用子表视图控制器吗?布拉瓦。如果某些UITableViewController满足需要,我们也可以使用它。@vin然后您将如何告诉刷新操作停止?(你会运行什么代码?@playbasegames你可以使用EndRefresh方法停止此方法不会通过向上拉tableView来刷新,只能通过向下拉来刷新。我同意Bot和rilar的观点