简体   繁体   中英

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 )

I have a tableViewController.h file that looks like this:

#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:

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

@interface ICIRecordingsViewController ()

@end

The ICIrecordingCell.h file looks this:

#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

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:

-(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 . The accessory seems to grab the touch event and is not passing it through to the buttons created by the SWTableViewCell . For now, I have disabled the accessory view and delegate calls are occurring as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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