2011-04-12 11 views
0
  • (のUITableViewCell *)のtableView:(のUITableView *)のtableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {テーブルビュー画像負荷問題(のTableCell FOTフルコード)

    辞書= [QuestionMutableArray objectAtIndex:0]。

    静的NSString * CellIdentifier = @ "BeginingCell";

    BeginingCell * cell =(BeginingCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    (セル== NIL){

    NSArray *topLevelObjects=[[NSBundle mainBundle] loadNibNamed:@"BeginingCell" owner:self options:nil ]; 
    
    for(id CurrentObject in topLevelObjects) 
    { 
        if ([CurrentObject isKindOfClass:[BeginingCell class]]) { 
    
         cell=(BeginingCell *) CurrentObject; 
         break; 
        } 
    } 
    

    }

    //セルを設定する場合。

    (indexPath.row == 0){

    cell.SectionTitle.text=[dictionary objectForKey:@"question"]; 
    cell.Option1.text=[dictionary objectForKey:@"option1"]; 
    cell.Option2.text=[dictionary objectForKey:@"option2"]; 
    cell.Option3.text=[dictionary objectForKey:@"option3"]; 
    cell.Option4.text=[dictionary objectForKey:@"option4"]; 
    
    
    UIImage *imgDef=[UIImage imageNamed:@"man_kirstie_alley.jpg"]; 
    [cell.myImageView setImage:imgDef]; 
    
    
    
    
    [MyTestArray release]; 
    
    [cell.button1 setTitle:@"A." forState:UIControlStateNormal]; 
    [cell.button2 setTitle:@"B." forState:UIControlStateNormal]; 
    [cell.button3 setTitle:@"C." forState:UIControlStateNormal]; 
    [cell.button4 setTitle:@"D." forState:UIControlStateNormal]; 
    

    }

    戻りセルであれば、

}

+0

これは、「cellForRowAtIndexPath」の完全なコードですか? "cellForRowAtIndexPath"メソッドで完全なコードを投稿してください。 – Saurabh

+0

詳細を提供する必要がありますか、エラーメッセージはありますか?どのコード行がエラーを投げていますか? – JFoulkes

答えて

0

私はあなたが最初のセルを作成しなければならないと思います。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

//---try to get a reusable cell--- 

UITableViewCell *cell = [tableView 
    dequeueReusableCellWithIdentifier:CellIdentifier]; 

//---create new cell if no reusable cell is available--- 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
      reuseIdentifier:CellIdentifier] autorelease]; 
} 

//---You would set the image here--- 
UIImage *imgDef=[UIImage imageNamed:@"man_kirstie_alley.jpg"]; 
cell.image = imgDef; 

return cell; 
+0

はい私は同じことをやっています。私はコード全体を投稿しませんでした。しかし、働いていません。ここでは壊れています:[cell.myImageView setImage:imgDef]; –

+0

@ sohel14-cse-ju:コンソールからエラーメッセージを投稿してください。コンソールからXCodeを表示するにはメニュー –

+0

から「実行>コンソール」を選択してください例外はありません:***キャッチされていない例外「NSInvalidArgumentException」、理由: ' - [BeginingCell myImageView]:インスタンス0x4d2b0c0' –