2012-01-11 9 views
0

本当に面倒ですが、何らかの理由で自分のImageViewがセルビューのすぐ後ろに表示されます。クリッピングをオフにすると、画像がセルのすぐ後ろに表示されます。参考までに、写真ライブラリから選択してPNGに変換した画像を表示しようとしています。UITableViewCell:画像はCellビューの後ろに表示されます

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

    static NSString *headerCellID = @"FormHeaderCellView"; 
    if(indexPath.section==0 && indexPath.row==0) //Header cell 
    { 
     FormHeaderCellView *cell = (FormHeaderCellView *)[self.tableView dequeueReusableCellWithIdentifier:headerCellID]; 

     if (cell == nil) 
     { 
      NSArray *topLevelObjects =[[NSBundle mainBundle] loadNibNamed:headerCellID owner:nil options:nil]; 

      for (id currentObject in topLevelObjects) 
      { 
       if([currentObject isKindOfClass:[UITableViewCell class]]) 
       { 
        cell = (FormHeaderCellView *) currentObject; 
        break; 
       } 
      } 

     } 


     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
     NSString *documentsDirectory = [paths objectAtIndex:0]; 
     NSString *file = [documentsDirectory stringByAppendingPathComponent:@"logo.png"]; 

     if([[NSFileManager defaultManager] fileExistsAtPath:file]) 
     { 
      UIImage *img=[[UIImage alloc] initWithContentsOfFile:file]; 

      [cell.logoImage setImage:img]; 
     } 


     [cell.textLabel setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"userName"]]; 

     [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 

     return cell; 

    } 

私は視覚的に細胞の背後の画像を見ることができるので、すべてがうまく読み込まれているようです。 あなたの助けに感謝します。

更新:いくつかのテストを行なったし、ペン先に私がバンドル内の任意の画像に logoImageのイメージプロパティを設定した場合、画像がうまく表示されます。だから問題は、ドキュメントディレクトリ(写真ライブラリから保存されたもの)から読み込まれたイメージを表示することです。

+0

ここで、frame.logoImageのフレームを作成していますか? –

+0

FormHeaderCellViewはUITableViewCellのサブクラスで、logoImageはIBOutlet UIImageViewプロパティです。 NIBで私は接続をちょうどうまく接続している。 – jAmi

+0

NIBで、logoImageが他のすべての上にあることを確認してください。 –

答えて

1

私は近くにMacを持っていないので、コード内のエラーについてお詫び申し上げます。

logoImageが他のビューよりも優れていますか?セルクラスで次の操作を実行してください。

[self.view addSubview:self.logoImage]; 
[self.view bringSubviewToFront:self.logoImage]; 

これは、ロゴビューをセルの他のすべてのサブビューの上に配置する必要があります。

希望します。

+0

を試してみました。働いていない。 – jAmi

関連する問題