1 つのテーブル ビュー ベースのアプリケーションを作成しています。2 つのラベル、1 つの画像、1 つのボタンを含むテーブルのカスタム テーブル セルを作成しました。テーブル ビュー データ ソース メソッドは正しく機能しています。カスタム セルとビュー コントローラー クラスの両方に xib を使用しており、デリゲートとデータ ソースをファイルの所有者に接続しています。しかし、問題は、テーブルの行を選択すると、didSelectRowAtIndexPath が起動しないことです。前述のように、発砲する唯一の方法は、セルを約 3 ~ 4 秒間押し続けることです。なぜこれが起こっているのか誰にも分かりますか?
ご指摘ありがとうございます...
これが私のテーブルビューメソッドです..
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [finalAddonsArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
NewCustomCell *cell = (NewCustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib=[[NSBundle mainBundle]loadNibNamed:@"NewCustomCell" owner:self options:nil];
cell=[nib objectAtIndex:0];
}
Addons *addons1=[[Addons alloc]init];
addons1= [finalAddonsArray objectAtIndex:indexPath.row];
if (addons1.data == nil) {
cell.ivCategory.image = [UIImage imageNamed:@"blogo.jpg"];
}
else
{
cell.ivCategory.image=[UIImage imageWithData:addons1.data];
}
cell.lblTitle.text = addons1.name;
if (addons1.price == nil) {
cell.lblPrice.text = nil;
}
else{
cell.lblPrice.text = [NSString stringWithFormat:@"%@ rs",addons1.price];
}
[cell.button addTarget:self
action:@selector(editButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
cell.button.tag=indexPath.row;
index = indexPath;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"sjcjksbcjksbcfkebscf1234567890");
}
もう1つ、カスタムセルの代わりにデフォルトのUITableViewCellを使用している場合、問題も同じで、デリゲートメソッドが起動しないことがわかります。
カスタム セル プロパティ: