Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何向上添加pull tableview以刷新uitableview中的数据_Iphone_Ios_Uitableview_Uiviewcontroller - Fatal编程技术网

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的观点