2013-10-25 38 views
0

我已经创建了自定义tablview_cell,并在tableview中的单元格内添加更多按钮。当我在模拟器中运行时,其工作良好。但在设备上几乎不能滚动。有什么方法可以解决这个问题,请让我知道。TableView卡在iPhone中滚动

感谢提前

我试试这个:

- (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供大家参考。

enter image description here

+0

你能提供你的代码? –

+0

off-course plz见上面我现在有更新。 – SampathKumar

+0

由于内存问题,您的tableview卡住了。你打电话给UIButton或任何其他方法显示图像的任何方法 –

回答

0

试试这个,

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *[email protected]"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; 

} 
+0

再次出现同样的问题 – SampathKumar