iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios7 – SWTableViewCell一次显示一个菜单大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用SWTableViewCell在tableView中显示我的friendsList.根据代码一切正常.问题是,我一次只需要一个活动单元.现在我可以通过一个一个地滑动来刷所有单元格的菜单.我想要的是,当我在另一个单元格上滑动时,前一个单元格应该转到其原始状态.

这是我的单元格代码

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath{
NSMutableArray *leftUtilityButtons = [NSMutableArray new];


[leftUtilityButtons sw_addUtilityButtonWithColor:
 [UIColor colorWithRed:0.07 green:0.75f blue:0.16f alpha:1.0]
                                            icon:[UIImage imag@R_696_8371@d:@"about-icon-md.png"]];
[leftUtilityButtons sw_addUtilityButtonWithColor:
 [UIColor colorWithRed:0.07 green:0.75f blue:0.16f alpha:1.0]
                                            icon:[UIImage imag@R_696_8371@d:@"chat-4-64.png"] ];
static NSString* identifier=@"addContactCell";

Cell *cell=(Cell *)[tableView dequeueReusableCellWithIdentifier:identifier];
Cell __weak * weakCell = cell;


[cell setAppearanceWithBlock:^{
    weakCell.containingTableView = tableView;


    weakCell.leftUtilityButtons = leftUtilityButtons;


    weakCell.delegate = self;
} force:NO];
if (cell==nil)
{

    SWTableViewCell *cell = (SWTableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifier];

    if (cell == nil) {

        cell = [[SWTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                      reusEIDentifier:identifier
                                  containingTableView:self.table // Used for row height and SELEction
                                   leftUtilityButtons:leftUtilityButtons
                                  rightUtilityButtons:nil];
        cell.delegate = self;
    }
    return  cell;
    }

cell.BACkgroundColor=[UIColor clearColor];
[cell.contentView.layer setBorderColor:[UIColor colorWithRed:0.15f green:0.47f blue:0.17f alpha:0.1].CGColor];

[cell.contentView.layer setBorderWidth:1.0f];
indexvalueRow = indexPath.row;
indexValueSection =indexPath.section;

friendUser= [self findFriendUser];


[friendUser fetchIfNeededInBACkgroundWithBlock:^(PFObject *object,NSError *error) {
    if (!error)
    {
        if (object) {


        NSLog(@"friend user = %@",friendUser);
        NSString *friendName = [NSString StringWithFormat:@"%@ %@",friendUser[@"FirstName"],friendUser[@"LastName"] ];


        cell.nameLabel.text= friendName;
        cell.nameLabel.textColor = [UIColor darkGrayColor];
        PFFile *userImageFile = friendUser[@"profilePic"];

        [userImageFile getDataInBACkgroundWithBlock:^(NSData *imageData,NSError *error)
         {

             if (!error) {

                 //NSLog(@"%@",imageData);
                 cell.profileImage.image = [UIImage imageWithData:imageData];


             }
         }];
        }}
}];


return cell;

}

解决方法

实现这个委托方法也是..

- (BOOL)swipeableTableViewCellShouldHideUtilityButtonsOnSwipe:(SWTableViewCell *)cell {
    return YES;
}

大佬总结

以上是大佬教程为你收集整理的ios7 – SWTableViewCell一次显示一个菜单全部内容,希望文章能够帮你解决ios7 – SWTableViewCell一次显示一个菜单所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。