1

私はこれを使用しています: http://blog.leahculver.com/2010/12/iphone-pull-to-refresh.html私のアプリで機能を更新するためのプルを作成します。しかし、「プルダウンして更新...」、「リリースして更新...」、および「読み込み中...」というテキストが表示されません。

ファイルをプロジェクトにコピーし、QuartzCore フレームワークにリンクし、View Controller の .h ファイルを変更して、PullRefreshTableViewController のサブクラスにしただけです。次に、refresh メソッドを追加しました。

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; }

ログがコンソールに出力されることはありません

問題がどこにあるのか本当にわかりませんか?

4

3 に答える 3

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;
}

よろしくお願いします

于 2011-05-10T08:39:25.613 に答える
0

以下を使用して PullRefreshTableViewController をインスタンス化してみてください。

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

initWithSyle を使用して UITableViewCell をインスタンス化しても、UITableViewController サブクラスには影響しません。

別の方法は、PullRefreshTableViewController クラスを編集して -(id)init メソッドを initWithStyle と同様の方法でオーバーライドすることです。

于 2011-02-09T06:32:18.113 に答える
0

テキストが定義されている場所を探している場合は、PullRefreshTableViewController.m の 43 行目にあります。

これが役立つことを願っています(そうでない場合は、私の回答に投票することを忘れないでください)

M.

于 2011-02-06T22:36:45.450 に答える