zoukankan      html  css  js  c++  java
  • IOS -- UITableView里面点击一个cell改变其他cell的设置

    CustomTableViewCell.h

    #import <UIKit/UIKit.h>
    
    @interface CustomTableViewCell : UITableViewCell
    @property (nonatomic, strong) IBOutlet UIImageView *taskUIimage;
    @property (nonatomic, strong) IBOutlet UILabel *taskName;
    @property (nonatomic, assign) BOOL isSelected;
    
    @end

    CustomTableViewCell.m

    #import "CustomTableViewCell.h"
    
    @implementation CustomTableViewCell
    -(void)setSelected:(BOOL)selected animated:(BOOL)animated{
      
        [self setSelected:selected];
        [super setSelected:selected animated:animated];
        
        
    }
    -(void)setSelected:(BOOL)isSelected{
        _isSelected = isSelected;
        if (_isSelected) {
            _taskName.text= @"YES";
        }
        else{
            _taskName.text= @"NO";
        }
    }
    @end

    ViewController.m

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSString *reuseIdentifier=@"reuseIdentifier";
        CustomTableViewCell *cell=nil;
        cell=[tableView dequeueReusableCellWithIdentifier:reuseIdentifier forIndexPath:indexPath];
        if(cell==nil)
        {
            cell=[[CustomTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        }
        cell.taskUIimage.image=[UIImage imageNamed:@"chongwu1019.jpg"];
        cell.isSelected = NO;
        //默认选中第五行
        if (indexPath.row == 4) {
            [tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
        }
        
        return cell;
        
    }
  • 相关阅读:
    c#新语法
    关于js 原生原生链
    网站置灰
    ie时间格式NAN-NAN-NAN
    关于vue+element对ie9的兼容el-upload不支持在IE9上传
    屏幕录制+网页页面截图
    javascript -数组常用方法
    javascript -字符串常用方法
    JavaScript 实用技巧
    vue兼容ie
  • 原文地址:https://www.cnblogs.com/qiyiyifan/p/7641989.html
Copyright © 2011-2022 走看看