UIViewController内的PullToRefresh TableView [英] PullToRefresh TableView inside UIViewController

查看:39
本文介绍了UIViewController内的PullToRefresh TableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIViewController ,它也是 UITableViewDelegate 以及在FirstView.xib中创建的 UITableView 的其他内容./p>

I've got a UIViewController which is also the UITableViewDelegate, amongst other things, for a UITableView, created in FirstView.xib

@interface FirstViewController : UIViewController <
    UITextFieldDelegate, 
    UITableViewDelegate, 
    UITableViewDataSource
> {

UITableView *searchResults; // this is the property for the table view
...

}

我希望此表视图使用PullToRefresh: https://github.com/leah/PullToRefresh,但是那里的文档仅说明了如何使用该类作为视图控制器的子类

I want this table view to make use of PullToRefresh: https://github.com/leah/PullToRefresh, but the documentation there only explains how to make use of the class as a sub class of the view controller

#import "PullRefreshTableViewController.h"

@interface DemoTableViewController : PullRefreshTableViewController {
    NSMutableArray *items;
}

我的应用程序使用Tab栏作为根视图控制器,谁能向我解释如何将 UITableView 制作为PullRefreshTableView?当我没有 UITableViewController 进行编辑时?

My app uses a Tab bar as the root view controller, can anyone explain to me how I can make the UITableView into a PullRefreshTableView? When I don't have a UITableViewController to edit?

推荐答案

秘密在于滚动视图委托方法,由于您充当表委托,因此您已经可以对其进行响应.此 article 为创建自己的提要刷新提供了良好的开端.

The secret is in the scroll view delegate methods which you can already respond to since you are acting as the tables delegate. This article provides a good start to create your own pull to refresh.

  • -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
    这将让您知道用户何时开始拖动滚动视图,以便您可以开始检查是否刷新.

  • - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
    This will let you know when the user starts dragging the scrollview so you can begin checking whether to refresh or not.

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
这使您可以在滚动时进行必要的过渡(主要是交换文本和翻转箭头)

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
This allows you to make necessary transitions while scrolling (mainly swapping text and flipping the arrow)

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollViewwillDecelerate:(BOOL)减速
在这里,您可以确定用户是否向下拖动足够远以开始刷新.

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
This is where you decide if the user has dragged far enough down to start the refresh.

这篇关于UIViewController内的PullToRefresh TableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆