2011-02-06 54 views
1

我一直在使用此:http://blog.leahculver.com/2010/12/iphone-pull-to-refresh.html使我的应用程序中的拉动刷新功能。 但我不能看到文本“下拉刷新...”,“释放刷新...”和“加载...”。在iPhone上拉到刷新不按预期方式工作

所有我所做的就是将文件复制到我的项目,对QuartzCore框架链接,并改变了我的视图控制器的.h文件所以它是PullRefreshTableViewController的子类。然后我添加了刷新方法。

看来,PullRefreshTableViewController中的initWithStyle方法永远不会被执行。 但我应该在我的tableViewcellForRowAtIndexPath。

​​

从PullRefreshTableViewController.m的initWithStyle方法:

- (id)initWithStyle:(UITableViewStyle)style { 
self = [super initWithStyle:style]; 
if (self != nil) { 
    textPull = [[NSString alloc] initWithString:@"Pull down to refresh..."]; 
    textRelease = [[NSString alloc] initWithString:@"Release to refresh..."]; 
    textLoading = [[NSString alloc] initWithString:@"Loading..."]; 
    NSLog(@"in"); 
} 
NSLog(@"out"); 
return self; } 

日志从不打印到控制台上

我真的不能看到问题出在哪里?

+1

在当前状态下回答这个问题是不可能的。例如,当您尝试执行构建时会发生什么?发生什么错误? – 2011-02-06 21:31:24

回答

2

有同样的问题。 想通了,不initWithStyle被称为替代的initWithCoder被称为....

因此解决您的问题插入按照您的PullRefreshTableViewController.m 代码,它就像一个魅力

-(id)initWithCoder:(NSCoder *)aDecoder{ 
NSLog(@"initWithCoder"); 
self = [super initWithCoder:aDecoder]; 
if (self != nil) { 
    textPull = [[NSString alloc] initWithString:@"Pull down to refresh..."]; 
    textRelease = [[NSString alloc] initWithString:@"Release to refresh..."]; 
    textLoading = [[NSString alloc] initWithString:@"Loading..."]; 
} 
return self; 
} 

问候

0

如果你正在寻找的文本被定义在哪里,它是在PullRefreshTableViewController.m

希望这有助于43线(如果它不要忘了投我的答案了)

M.

0

尝试实例化PullRefreshTableViewController有:

PullRefreshTableViewController *tableViewController = [[PullRefreshTableViewController alloc] initWithStyle:UITableViewStylePlain];

实例化使用initWithSyle的UITableViewCell不会对你的UITableViewController子类产生任何影响。

另一种方法是编辑PullRefreshTableViewController类重写 - (ID)init方法以类似的方式与initWithStyle完成:

相关问题