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;
        
    }
  • 相关阅读:
    tornado-cookies+pycket 验证
    解决form表单通过ajax时,required失效问题
    如何判断一个文件是否存在
    django中@property装饰器的运用
    RestFul API接口设计风格介绍和核心功能(概念)
    python中各个response使用
    Python的命名规则
    break和continue的区别
    LOCK接口
    API
  • 原文地址:https://www.cnblogs.com/qiyiyifan/p/7641989.html
Copyright © 2011-2022 走看看