Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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上拉刷新未按预期工作_Iphone_Xcode_Ios4_Pull To Refresh - Fatal编程技术网

在iphone上拉刷新未按预期工作

在iphone上拉刷新未按预期工作,iphone,xcode,ios4,pull-to-refresh,Iphone,Xcode,Ios4,Pull To Refresh,我一直在使用这个:在我的应用程序中使用pull to refresh功能。 但我看不到文本“下拉刷新…”、“释放刷新…”和“加载…” 我所做的只是将文件复制到我的项目中,链接到QuartzCore框架,并更改了视图控制器的.h文件,使其成为PullRefreshTableViewController的子类。然后我添加了刷新方法 PullRefreshTableViewController中的initWithStyle方法似乎从未执行过。 但我应该是,在我的tableViewcellForRowA

我一直在使用这个:在我的应用程序中使用pull to refresh功能。 但我看不到文本“下拉刷新…”、“释放刷新…”和“加载…”

我所做的只是将文件复制到我的项目中,链接到QuartzCore框架,并更改了视图控制器的.h文件,使其成为PullRefreshTableViewController的子类。然后我添加了刷新方法

PullRefreshTableViewController中的initWithStyle方法似乎从未执行过。 但我应该是,在我的tableViewcellForRowAtIndexPath中

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

cell.textLabel.text = @"Text";

return cell; }
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; }
日志永远不会在控制台中打印


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

如果要查找文本的定义位置,它位于PullRefreshTableViewController.m的第43行

希望这有帮助(如果没有,别忘了投票支持我的答案)


M.

尝试使用以下命令实例化PullRefreshTableViewController:

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

使用initWithStyle实例化UITableViewCell不会对UITableViewController子类产生任何影响

另一种方法是编辑PullRefreshTableViewController类,以类似于initWithStyle的方式重写-(id)init方法:

具有相同的问题。 发现调用的不是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;
}

致以最良好的祝愿

以目前的状态,不可能回答这个问题。例如,当您尝试执行构建时会发生什么?发生了什么错误?我已将您作为答案提供的附加信息与您的问题合并在一起。以后,如果您需要澄清,请编辑您的问题。