• TableView中改变Button按钮状态


    #Cell

        _followBtn = [[UIButton alloc]initWithFrame:CGRectMake(kMainApplicationWidth-79.0f, 20.0f, 67.0, 30.0f)];
        _followBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f];
        [_followBtn  setTitleColor:UIColorFromRGB(0XFFC600) forState:UIControlStateNormal];
        [_followBtn setTitleColor:UIColorFromRGB(0XFEFEFE) forState:UIControlStateSelected];
        UIImage *onImage = [[UIImage imageNamed:@"bt_focus_on"] resizableImageWithCapInsets:UIEdgeInsetsMake(5.0f, 5.0f, 5.0f, 5.0f)];
        UIImage *onPressImage = [[UIImage imageNamed:@"bt_focus_onpress"] resizableImageWithCapInsets:UIEdgeInsetsMake(5.0f, 5.0f, 5.0f, 5.0f)];
        UIImage *onChooseImage = [[UIImage imageNamed:@"bt_focus_onchoose"] resizableImageWithCapInsets:UIEdgeInsetsMake(5.0f, 5.0f, 5.0f, 5.0f)];
        [_followBtn setBackgroundImage:onImage forState:UIControlStateNormal];
        [_followBtn setBackgroundImage:onPressImage forState:UIControlStateHighlighted];
        [_followBtn setBackgroundImage:onChooseImage forState:UIControlStateSelected];
        [_followBtn setTitleColor:UIColorFromRGB(0XFEFEFE) forState:UIControlStateSelected];
        [_followBtn setTitle:@"关注" forState:UIControlStateNormal];
        [_followBtn setTitle:@"已关注" forState:UIControlStateSelected];
        _followBtn.selected = NO;

       [self.contentView addSubview:_followBtn];

    #TableView

        [cell.followBtn addTarget:self action:@selector(onFollowButtonsClickEvent:) forControlEvents:UIControlEventTouchUpInside];
        [cell.followBtn setTag:indexPath.row];

    #Pragma

    - (void)onFollowButtonsClickEvent:(id)sender{
        UIButton *btn = (UIButton*)sender;
        NSInteger index = btn.tag;
        ICUser *fansItem = (ICUser*)[self.fansDataArray objectAtIndex:index];
        if (btn.isSelected) {
            [btn setSelected:NO];
            ICUserFollowRequest *req = [[ICUserFollowRequest alloc]initWithUserId:ME_ID otherId:fansItem.userId action:@"2"];
            [req cancel];
            [req start];
                            }
        else {
            [btn setSelected:YES];
            ICUserFollowRequest *req = [[ICUserFollowRequest alloc]initWithUserId:ME_ID otherId:fansItem.userId action:@"1"];
            [req cancel];
            [req start];
            }
    }

     
  • 相关阅读:
    [root@py ~]# watch -n 1 ifconfig 求解释
    25 个常用的 Linux iptables 规则
    linux shell 字符串操作(长度,查找,替换)详解
    linux高级网络配置 ip别名,接口绑定
    初始版本控制工具-Git
    详解 TCP 连接的“ 三次握手 ”与“ 四次挥手 ”
    wireshark_users
    wireshark抓包基础步骤及PPPOE拨号抓包过程分析
    ARP原理与ARP攻击
    PPPOE 详解
  • 原文地址:https://www.cnblogs.com/i0ject/p/4033099.html
Copyright © 2020-2023  润新知