【问题标题】:Pull to refresh doesn't show text or picture in tableview拉动刷新不会在表格视图中显示文本或图片
【发布时间】:2012-03-05 12:29:48
【问题描述】:

我将https://github.com/leah/PullToRefresh 导入到我的项目中。它的工作原理如下:我可以拉下我的 tableview 并刷新自己。问题是我在刷新时没有得到任何文本或箭头。我尝试导入和子类化它(有效,但没有文本或箭头)。我直接在我的课堂上实现了它(仍然有效,但没有文字或箭头)。希望有人有解决方案。

这是我在课堂上的称呼:

在我的 .h 文件中,我将其导入

#import "PullRefreshTableViewController.h"

还有子类

@interface Friends : PullRefreshTableViewController

在我的 .m 文件中,我按照说明进行操作并添加:

-(void)refresh {

[self performSelector:@selector(doXMLParsing) withObject:nil afterDelay:1.0];}

然后放

[self stopLoading];

在我的方法结束时。

它做了它应该做的事,遗憾的是没有显示文本或箭头。

【问题讨论】:

  • 你链接到 QuartzCore 框架了吗?
  • 嗯,里面的demo工程,行吗?
  • 是的,工作正常。其他人也有这个问题并将其发布在 github 问题中,并通过初始化 viewDidLoad 中的字符串来解决。遗憾的是,这对我不起作用。
  • 字符串在setupStrings 方法中设置。标签和箭头在addPullToRefreshHeader 方法中作为子视图添加。这些方法被调用了吗?
  • 是的。为了确保,我还在 viewDidLoad 中实现了它们。

标签: ios tableview pull-to-refresh


【解决方案1】:

使用下面的代码在 tableView 中简单地应用 pull 来刷新。

在视图控制器的头文件中声明 refreshControl 为:-

UIRefreshControl *refreshControl;

并在实现文件中用作:-

refreshControl=[[UIRefreshControl alloc] init];
refreshControl.tintColor=t.tableCellSelectionColor;
[refreshControl setAttributedTitle:[[NSAttributedString alloc] initWithString:@"Refresh Title"]];//Optional

[refreshControl addTarget:self action:@selector(reloadTable) forControlEvents:UIControlEventValueChanged];
[tblView addSubview:refreshControl];

-(void)reloadTable
{
    // do your stuff here....
    [tblView reloadData];
    [refreshControl endRefreshing];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多