1

私はこれが何度も何度も尋ねられたことを知っています。与えられたすべての解決策を試しましたが、それでもうまくいきませんでした。データソースとデリゲートをテーブル ビューに設定し、ポインタにも設定しました。

これが私のコードです:

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

メソッドでを呼び出しましreloadDataviewDidLoad:。問題は、メソッドを起動し、行数を正しく取得しましたが、このメソッドを起動numberOfRowsInSection:しませんでしたcellForRowAtIndexPath:

解決策はありますか?

4

3 に答える 3

0

次のコードを使用します。

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

コードで resultsoap 配列を宣言した後。

于 2014-04-22T07:11:25.040 に答える
-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];
}

そして、私たちのケースでは TableView の IBOutlet を、その MyTableView を XIB ファイルの TableView に接続してください。 私の場合、そのgetclientTable。

于 2012-05-04T08:19:43.393 に答える