2012-03-25 13 views
-1

カスタムUITableViewCellを作成し、UITableViewにセルを追加すると、XMLデータから情報をダウンロードし、i ProgressViewを使用してプロセスの進捗状況を表示したいのですが、私の質問は、どのようなインデックス行をどのように検出して、プログレスバーを変更してからそれを隠す必要があるのでしょうか... ...作成したばかりの行のインデックスパスは何ですか?カスタムUITableViewCellにUIProgressViewを追加し、インデックス行を検出します

:私はこのように私のカスタムUITableViewCellのから情報を取得

cellForRowAtIndexPath:(NSIndexPath *)indexPath 

UILabel *label; 

label = (UILabel *)[cell viewWithTag:1000]; 
label.text = [[managedObject valueForKey:@"firstName"] description]; 

ので、どのように私は、その後変更するには、行のインデックスパスの行を追加した知ることができますプログレスバー?

+0

hey @Piero値を取得する場合や、progressviewの値を変更したい場合は、そのタグをセルからフェッチすることができます。 – Leena

+0

しかし、どのようなインデックスがセルを持っているのか知っていますか? – Piero

+0

progressView.tag = indexPath.rowを設定して、progressviewで何をしたいかを指定します。 – Leena

答えて

0

私はあなたが何を求めているのか分かりません。 indexPathは、作成したばかりの行のIndexPathです。この値にプロパティを設定しますが、そのプロパティには作成されたLAST行のIndexPathのみが含まれます。

に例を示すように更新:

方法1 - あなたはcellForRowAtIndexPath内から他のメソッドを呼び出すことはありません。

#import "MyViewController.h" 

@interface MyViewController() 
    @property(nonatomic,strong) NSIndexPath *lastIndexPathCreated; 
@end 

@implementation MyViewController 
@synthesize lastIndexPathCreated; 
:あなたの.mファイルに

:この場合、あなたはタイプNSIndexPathの私有財産が必要になります(唯一のプライベートプロパティ宣言を置くことをお見せするためにMyViewControllerのインポートと@interface宣言のコードが含まれて

...

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
// All your other cell setup code 

self.lastIndexPathCreated = indexPath; 
return cell; 
} 

-(void)someOtherMethod { 
    // The last IndexPath of the row LAST created is self.lastIndexPathCreated 
} 

方法2:これは、あなたがcellForRowAtIndexPath内から他のいくつかのメソッドを呼び出すことを前提としています

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    // All your other cell setup code 
    [self myOtherMethodWithIndexPath:indexPath]; 
    return cell; 
} 

-(void)myOtherMethodWithIndexPath:(NSIndexPath *)lastIndexPath { 
    // Do something with lastIndexPath 
} 

希望する場合は

+0

これでコード内の別のメソッドで、作成した最後の行のインデックスパスを取得して、進行状況の表示? – Piero

+0

私は行を追加し、コアデータ(行の情報を取得する場所)にcellewforindexパスを挿入してデータをロードし、テーブルビューのすべての行をリロードし、 lastIndexPathCreatedテーブルビューの位置を変更して、インデックスパスも変更します。 – Piero

+0

はい、IndexPathはテーブルビューのすべての行について変更されます。 –

関連する問題