我已创建自定义tablview_cell并在tableview中的单元格内添加更多按钮。当我在模拟器中运行时,它的工作正常。但在设备中几乎没有卡住滚动。有什么方法可以解决这个问题,请告诉我。
谢谢你提前
我试试这个:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 250;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString * identifier = @"Cell+Identifier";
Custom_Cell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if(cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Custom_Cell" owner:self options:nil];
cell = [nib objectAtIndex:0];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.btn1 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn2 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn3 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn4 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn5 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn6 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn7 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn8 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn9 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn10 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn11 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn12 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
}
cell.label.text = [NSString stringWithFormat:@"%d",indexPath.row];
return cell;
}
-(void)selected_files:(id)sender
{
View_2 *v2 = [[View_2 alloc]init];
[self.navigationController pushViewController:v2 animated:YES];
}
下面我提到了Custom_Cell供您参考。
答案 0 :(得分:0)
试试这个,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier=@"cell";
Custom_Cell *cell = (Custom_Cell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"Custom_Cell" owner:self options:nil];
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[UITableViewCell class]])
{
cell = (Custom_Cell *) currentObject;
break;
}
}
}
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[cell.btn1 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn2 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn3 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn4 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn5 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn6 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn7 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn8 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn9 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn10 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn11 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
[cell.btn12 addTarget:self action:@selector(selected_files:) forControlEvents:UIControlEventTouchUpInside];
cell.label.text = [NSString stringWithFormat:@"%d",indexPath.row];
return cell;
}