>我有一个UITableViewCell
里面有 3 UIButton
秒,用于减少计数器。长按其中一个按钮时,我想将计数器设置为 0。
在界面生成器中执行此操作时,我将Long Press Gesture Recognizer
拖到button
上,并将选择器连接到UITableViewCell.m
中指定的IBAction
。
这就是我所做的一切,但是当我运行该应用程序时,它给出了以下错误。
'NSInternalInconsistencyException',
reason: 'invalid nib registered for identifier (editQuotaCell)
- nib must contain exactly one top level object which must be a UITableViewCell instance'
我错过了任何步骤吗?
只需在编码方面创建按钮,即可添加手势和选择器。它会起作用。检查波纹管代码
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];
if(cell == nil)
{
UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"];
cell.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:self action:@selector(select_Action:) forControlEvents:UIControlEventTouchUpInside];
[btn setTag:Selection_Tag];
[btn setBackgroundImage:[UIImage imageNamed:@"Demo03.png"] forState:UIControlStateNormal];
[btn setFrame:CGRectMake(0,0,tableView.frame.size.width,tableView.rowHeight)];
[cell.contentView btn];
//Add Your gestures here
}
return cell;
}