我想删除带有减号的红色按钮,并使删除按钮在向左滑动时显示,现在滑动不起作用

I want to remove the red button with the minus and make it so that the delete button shows up on swiping left now swiping isn't working

提问人:akshayTejus 提问时间:9/6/2023 最后编辑:HangarRashakshayTejus 更新时间:9/7/2023 访问量:44

问:

这是我的代码, 我想删除带有减号的红色按钮,并使删除按钮在向左滑动时显示,现在滑动不起作用。我检查了它默认显示红色按钮,但我在网上看到的视频使用了这种方法,但只需滑动没有带减号的红色按钮即可工作。UITableViewCellEditingStyleDelete

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *musicPlaylistCellId = @"feedCell";
    UITableViewCell *cell = nil;
    if(tableView == self.historyTableView){
        FeedCell *musicPlaylistCell = [self.historyTableView dequeueReusableCellWithIdentifier:musicPlaylistCellId];
        [musicPlaylistCell setContentWithPlaylist:[self.historyList objectAtIndex:indexPath.row]];
        cell = musicPlaylistCell;
    }
    else if (tableView == self.myMusicTableView) {
        UserFeedCell *musicPlaylistCell = [self.myMusicTableView dequeueReusableCellWithIdentifier:musicPlaylistCellId];
        musicPlaylistCell.isMyProfile = isMyProfile;
        
        //         [musicPlaylistCell addActionButtons:[self leftButtons] withButtonWidth:kJAButtonWidth withButtonPosition:JAButtonLocationRight];
        musicPlaylistCell.delegate = self;
        
        BOOL isLibrary = (self.btnLibraryTop.selected || self.btnLibrary.selected);
        musicPlaylistCell.isRecent = !isLibrary;
        Playlist *obj;
        if (isLibrary) {
            obj = (Playlist *)[self.myMusicList objectAtIndex:indexPath.row];
            musicPlaylistCell.btnPlaylistOwner.hidden = YES;
            musicPlaylistCell.vwActions.hidden = NO;
        }
        else
        {
            obj = (Playlist *)[self.aryRecentPlaylists objectAtIndex:indexPath.row];
            musicPlaylistCell.btnPlaylistOwner.hidden = NO;
            musicPlaylistCell.vwActions.hidden = YES;
        }
        
        if (obj.originalOwner != nil) {
            musicPlaylistCell.isMyProfile = NO;
        }
        
        [musicPlaylistCell setContentWithPlaylist:(isLibrary?[self.myMusicList objectAtIndex:indexPath.row]:[self.aryRecentPlaylists objectAtIndex:indexPath.row]) withTrackNumbers:NO];
        
        if (isLibrary) {
            if (indexPath.row == [self.myMusicList count] - 1)
            {
                [self launchReload];
            }
        }
        else
        {
            if (indexPath.row == [self.aryRecentPlaylists count] - 1)
            {
                [self launchReload];
            }
        }
        //        if (indexPath.row == rowReload){
        //            [musicPlaylistCell revealButtonsWithTopViewWithOffset:-60 swipeDirection:JASwipeDirectionLeft];
        //        }
        cell = musicPlaylistCell;
    }
    return cell;
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
    return true;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [self.myMusicList removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }
}

This is how it looks

iOS Objective-C UITableView 滑动

评论

0赞 HangarRash 9/7/2023
当表视图处于编辑模式时,将显示红色删除圆圈图标和移动图标。当表视图未处于编辑模式时,滑动删除功能有效。

答: 暂无答案