简体   繁体   English

未调用SWTableViewCell委托方法

[英]SWTableViewCell Delegate methods are not being called

I'm new to IOS so I'm not 100% sure why the delegate methods aren't being called in my implementation of SWTableViewCell (A library that can be found here: https://github.com/CEWendel/SWTableViewCell ) 我是IOS的新手,所以我不确定100%为什么在我的SWTableViewCell实现中未调用委托方法(可在此处找到一个库: https : //github.com/CEWendel/SWTableViewCell

I have a tableViewController.h file that looks like this: 我有一个tableViewController.h文件,看起来像这样:

#import <UIKit/UIKit.h>
#import "SWTableViewCell.h"
#import <AVFoundation/AVFoundation.h>

@interface ICIRecordingsViewController : UITableViewController <SWTableViewCellDelegate, AVAudioPlayerDelegate>
@property (nonatomic, strong) NSArray *documentArray;
@property (strong, nonatomic) AVAudioPlayer *audioPlayer;
@property (strong, nonatomic) SWTableViewCell *previousCell;
@end

And the tableViewcontroller.m file imports the following: 并且tableViewcontroller.m文件导入以下内容:

#import "ICIRecordingsViewController.h"
#import "ICIRecordingCell.h"

@interface ICIRecordingsViewController ()

@end

The ICIrecordingCell.h file looks this: ICIrecordingCell.h文件如下所示:

#import <UIKit/UIKit.h>
#import "SWTableViewCell.h"

@interface ICIRecordingCell : SWTableViewCell
@property (weak, nonatomic) IBOutlet UILabel *title;
@property (weak, nonatomic) IBOutlet UIButton *playButton;

@end

And the ICIRecordingCell.m file imports the ICIRecordingCell.h 并且ICIRecordingCell.m文件导入ICIRecordingCell.h

The Swipe gestures are registering on the individual cells and revealing the underlying buttons, but when I click on the buttons the delegate methods are not being triggered: Swipe手势正在各个单元格上注册并显示底层按钮,但是当我单击按钮时,不会触发委托方法:

-(void) swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index{
    switch(index){
        case 0:{
            UIActionSheet *shareActionSheet = [[UIActionSheet alloc] initWithTitle:@"Share" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Share on FaceBook", @"Share on Twitter", nil];
            [shareActionSheet showInView:self.view];

            [cell hideUtilityButtonsAnimated:YES];
            break;
        }
        case 1:{
            NSIndexPath *cellIndexPath = [self.tableView indexPathForCell:cell];
            //need to figure out how to delete the item from the file system
            [self.tableView deleteRowsAtIndexPaths:@[cellIndexPath] withRowAnimation:UITableViewRowAnimationLeft];
             break;
        }
        default:break;
    }
}

I've set a breakpoint on delegate methods but nothing gets hit when the buttons are hit. 我已经在委托方法上设置了一个断点,但是当按下按钮时没有任何东西被击中。 Any ideas? 有任何想法吗?

There appears to be an issue with accessory views on a row cell and SWTableViewCell . 行单元格和SWTableViewCell上的附件视图似乎存在问题。 The accessory seems to grab the touch event and is not passing it through to the buttons created by the SWTableViewCell . 该附件似乎抓住了触摸事件,并且没有将其传递给SWTableViewCell创建的按钮。 For now, I have disabled the accessory view and delegate calls are occurring as expected. 目前,我已禁用了附件视图,并且按预期进行委托调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM