2011-03-22 5 views
0

これは何度も繰り返し尋ねられています。私はすべての解決策を試しましたが、それでもうまくいきませんでした。私は、データソースを設定し、私のテーブルビューに委任し、また私のポインタに設定します。私は私のviewDidLoad:方法にreloadDataと呼ばれてきましたReloadDataはcellForRowAtIndexPathを起動しません

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section  { 
NSLog(@"%i", resultSoap.count); 
return resultSoap.count; 
} 


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

static NSString *CellIdentifier = @"Cell"; 

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

// Configure the cell. 

NSString *cellValue = [resultSoap objectAtIndex:indexPath.row]; 
cell.textLabel.text = cellValue; 
NSLog(@"Celldisplay"); 

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

return cell; 
} 

は、ここに私のコードです。問題は、それはnumberOfRowsInSection:メソッドを起動し、私は正しい行カウントを取得しますが、それはこのcellForRowAtIndexPath:メソッドを起動しませんでした。

+0

戻っている行は何行ですか?デバッグモードでは、resultSoapの内容を見ることができますか? – Peres

答えて

-3

適切な方法でベローズコードを追加してください。

あなたのヘッダファイルに

よりもテーブルビューをシンプルなコントローラを取り、追加があった場合の.h

#import <UIKit/UIKit.h> 
@interface TaskAndTax : UIViewController<UITableViewDelegate, UITableViewDataSource> 
{ 
    IBOutlet UITableView *MyTableView; 
} 
@property (nonatomic, retain) UITableView *MyTableView; 
@end 

とあなたの.mファイル

@synthesize MyTableView; 

-(void) viewWillAppear:(BOOL)animated 
{ 
    [MyTableView reloadData]; 
} 

をの親切に接続IBOutletで私たちの場合のTableView XIBファイルのTableViewへのMyTableView。あなたのコード内resultsoap配列を宣言した後

urtableview.delegate = self; 
urtableview.datasource = self; 

In My case Its getclientTable.

0

は、このコードを使用します。

0

テーブルビューのデータソース配列"resultsoap"が空の場合は、テーブルのreloadメソッドを呼び出す必要があります。 データソース配列が空でないことを確認し、配列にオブジェクトが保存されているかどうかを確認します。

numberOfRowsInSectionが0の場合、cellForRowAtIndexPathは呼び出されない可能性があるためです。 これはあなたの場合でなければなりません。

関連する問題