2016-04-01 8 views
1

私の要件は、テーブルビューのセルに円形のイメージを表示することです。その目的のために行のセルで私は私のimageviewのアウトレットのコーナー半径を与えました画像は円形の形式で表示されますが、スクロールするとセルが揺れているときにコーナーの半径のコードがうまくいけば、TabelView角の半径を指定するとセルが揺れますか?

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

    NSString *cellIdentifier [email protected]"notification"; 

    NotifiucationTableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    if (cell == nil) { 
     cell = [[NotifiucationTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier]; 
    } 

    ZSAnnotation *objArray = [personDetails objectAtIndex:indexPath.row]; 
    [cell.profilePic sd_setImageWithURL:[NSURL URLWithString:objArray.personImage] 
         placeholderImage:[UIImage imageNamed:@"profile-pic-big.png"]]; 

    cell.personDescription.text = objArray.personDescription; 
    cell.personTitle.text = objArray.personTitle; 
    myString = [[NSNumber numberWithFloat:objArray.rating] stringValue]; 
    km = [NSString stringWithFormat:@"%@%@", myString, @" KM"]; 

    cell.personNearbyDistance.text = km; 
    [cell.callButton addTarget:self action:@selector(callButtonAction:) forControlEvents:UIControlEventTouchUpInside]; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    cell.selectionStyle = UITableViewCellSelectionStyleNone; 
    cell.backgroundColor = [UIColor whiteColor]; 
    cell.profilePic.layer.cornerRadius = 30; 

    return cell; 
} 
+0

デバイスをチェックインしましたか?あなたは問題を抱えていますか? –

+0

はいiPadでチェックしました。問題があります –

+0

スクリーンショットをアップロードできますか? –

答えて

0

のように、セルクラスの「awakeFromNib」方式での細胞のUI設定を入れてみてください:あなたは「cellForRowAtIndexPath」の方法で、細胞のUIを更新しようとした場合のUITableViewCellは常に、再利用されているので

- (void)awakeFromNib{ 
    self.imageView.layer.cornerRadius = 30; 
} 

コードは、セルが表示される前に実行されますが、コードを "awakeFromNib"に入れると、tableViewがロードされているときにコードが数回だけ実行され、上下にスクロールしたときにコードが再度実行されることがあります。細胞は滑らかに見える。

0

セルの内側に角の半径を付けることができると思います。 セルがちらつく理由は、表ビューがセルをちらつくcellForItemAtIndexPathメソッド内でスクロールされたときに、tableViewがセルをデキューしようとするためです。あなたはペン先

-(void) awakwFromNib 
{ 
    self.yourImageView.cornerRadius = 30; 
    self.yourImageView.layer.maskToBounds = YES; 
} 
0

から目を覚ましに、このように行うことができます

if (cell.profilePic.layer.cornerRadius != 30){ 
    cell.profilePic.layer.cornerRadius = 30; 
    cell.profilePic.clipsToBounds = YES; 
} 

cell.profilePic.layer.cornerRadius = 30; 

を交換してみてください作成するときに、半径が1回だけ適用されますその方法細胞。

関連する問題