次のコードでUITableViewを開始しました。
ProductTableView *tableProd = [[ProductTableView alloc]initWithNibName:@"ProductTableView" bundle:nil];
xibファイルは存在します!
このテーブルを別のUIViewに表示しているので、次の方法でこのテーブルに追加します。
[content addSubview:tableProd.view];
xcodeを使用して標準のUITableViewを作成し、次の関数を設定しました。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}
- (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];
}
cell.textLabel.text = @"test";
return cell;
}
テーブルは、テストで満たされた10行でシミュレーターに表示されます。ただし、スクロールを開始し、最初のセルが画面を離れると、シミュレータがクラッシュしてEXC_BAD_ACCESSエラーが発生します。Instrumentsを使用してNSZombieを検出しようとしましたが、ソフトウェアがゾンビにフラグを付けました。残念ながら、このエラーを原因までさかのぼることはできません。
ここで何がうまくいかないのか誰かが知っていますか?