2

私は今UITableViewで作業していますが、私が持っているのは

MyClass.h

@interface MyClass : UIViewController {

}

@property (strong , strong) UILabel *name;

@property (strong , strong) UILabel *add;

MyClass.m

-(NSInteger)tableView:(UITableView *)atableView numberOfRowsInSection:(NSInteger)section{

return 3 ;
 }

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

static NSString *CellIdentifier = @"cell";
tableCell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
...................................................

return tableCell; 

}

numberOfRowsInSectionに i ブレークポイントを置くと、まったく実行されていないようです。それは今私を混乱させています。以前に遭遇したことがある場合は、アドバイスをお願いします。

ありがとう

4

1 に答える 1

3

これの最も一般的な原因は、ビュー コントローラーをテーブル ビュー デリゲートおよびデータソースとして設定していないことです。ストーリーボードに組み込まれている場合は、テーブルで接続インスペクターを選択し、それらのプロパティをビュー コントローラーにドラッグすることでこれを行うことができます。

それ以外の場合は、次のようなコードで設定します。

self.tableView.delegate = self;
self.tableView.datasource = self;
于 2012-04-18T00:44:14.240 に答える