2013-10-25 71 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