iOS疯狂详解之tableview编辑添加删除

JavaFx表格视图TableView设置单元格可编辑 阅读详情
//
//  VkoWLAccountVC.m
//  PocketUniversity
//
//  Created by long on 15-1-14.
//  Copyright (c) 2015年 WLong. All rights reserved.
//

#import "VkoWLAccountVC.h"
#import "VkoWLMoreTableViewCell.h"

#define kIcoArray @[@"消息",@"账号",@"版权"]
#define kTitleArray @[@"听筒模式",@"播放",@"清除缓存"]

@interface VkoWLAccountVC ()
{
    // 当前的编辑模式
    UITableViewCellEditingStyle _editingStyle;
    NSMutableArray *_icoArray;
    NSMutableArray *_titleArray;
}
@end

@implementation VkoWLAccountVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _icoArray = [NSMutableArray arrayWithArray:kIcoArray];
    _titleArray = [NSMutableArray arrayWithArray:kTitleArray];

    
    [self navTitle:@"账号管理" leftButtonHidden:NO];
    
    [self createView];
    
    _editingStyle = UITableViewCellEditingStyleDelete;

}

- (void)createView
{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.bgImageView.bottom, kUIScreenWidth, [self getMiddleViewHight]) style:(UITableViewStyleGrouped)];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.allowsSelectionDuringEditing = YES;  //编辑状态下可以选中
    [self.view addSubview:_tableView];
    
    
    self.rightButton.hidden = NO;
    self.rightButton.backgroundColor = [UIColor clearColor];
    [self.rightButton setImage:[UIImage imageNamed:@"编辑"] forState:(UIControlStateNormal)];
    [self.rightButton addTarget:self action:@selector(editButtonClick:) forControlEvents:(UIControlEventTouchUpInside)];
}

- (void)editButtonClick:(UIButton *)button
{
    [self deleteData];
}


#pragma mark --- UITableView 返回Cell ---
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"VkoWLMoreTableViewCell";
    
    VkoWLMoreTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
    if (cell == nil) {
        
        cell = [[VkoWLMoreTableViewCell alloc] initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:cellIdentifier] ;
        
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.iocImageView.image = [UIImage imageNamed:_icoArray[indexPath.row]];
    cell.labelTitle.text = _titleArray[indexPath.row];
    [cell.iocImageView.layer setMasksToBounds:YES];
    [cell.iocImageView.layer setCornerRadius:25 / 2];
    cell.arrowImageView.hidden = YES;

    
    return cell;
    
}

#pragma mark ---tableView dataSource---
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _titleArray.count;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 20+25;
}

#pragma mark --- 选中跳转 到详情界面 ---
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}


#pragma mark ---deit delete---
// 让 UITableView 和 UIViewController 变成可编辑状态
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    [super setEditing:editing animated:animated];
    
    [_tableView setEditing:editing animated:animated];
}

//  指定哪一行可以编辑 哪行不能编辑
- (BOOL) tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

//  设置 哪一行的编辑按钮 状态 指定编辑样式
- (UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return _editingStyle;
}

// 判断点击按钮的样式 来去做添加 或删除
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 删除的操作
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        
        [_titleArray removeObjectAtIndex:indexPath.row];
        [_icoArray removeObjectAtIndex:indexPath.row];

        
        NSArray *indexPaths = @[indexPath]; // 构建 索引处的行数 的数组
        // 删除 索引的方法 后面是动画样式
        [_tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimationLeft)];
        
    }
    
    // 添加的操作
    if (editingStyle == UITableViewCellEditingStyleInsert) {
        
        NSArray *indexPaths = @[indexPath];
        [_tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimationRight)];
        
    }
    
}

#pragma mark 删除数据
- (void)deleteData
{
    _editingStyle = UITableViewCellEditingStyleDelete;
    
    BOOL isEditing = self.tableView.isEditing;
    
    [self.tableView setEditing:!isEditing animated:YES];
}

- (void)addData
{
    _editingStyle = UITableViewCellEditingStyleInsert;
    
    BOOL isEditing = self.tableView.isEditing;
    
    [self.tableView setEditing:!isEditing animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end




更多iOS疯狂详解:http://blog.youkuaiyun.com/wanglongblog

iOS疯狂详解之SQlite数据库增删改查 // // SqLiteManager.h // MySqlite // // Created by long on 15/9/15. // Copyright (c) 2015年 WLong. All rights reserved. // #import #import "LanOuStudent.h" #import @interface SqLiteManager : NSO 阅读详情

相关推荐

ios-自定义编辑全选TableView.zip

自定义TableView编辑状态,可以全选单选,代码仅供参考没有封装。

iOS-TableView编辑(多行编辑)

TableView编辑(多行编辑)Demo下载地址- 插入链接 [ 下载地址 ]OC的tableview的选中、全选、取消全选demo,(纯代码手动打造) 洲洲哥的github主页。 —— [ 洲洲哥 ] 项目结构系统界面 编辑界面 全选功能和取消全选功能可以看一下demo单选功能实现(Block)/** * cell内容 */ -(UITableViewCell *)tabl...

whuizhou的专栏 1629

TableView删除,修改,编辑

TableView删除,修改,编辑,以及cell的移动

iOS UIKit:TableView之编辑模式(3)

一般table view有编辑模式和正常模式,当table view进入编辑模式时,会在row的左边显示编辑和重排控件,如图 42所示的编辑模式时的控件布局;左边的editing control有表 61的两种图标。 表 61 table view编辑控件 图标 描述 Deletion控件 In...

a567676的博客 337

iOS中tableview实现编辑、全选及删除等功能的方法示例

主要给大家介绍了关于iOS中tableview实现编辑、全选及删除等功能的相关资料,文中通过示例代码介绍的非常详细,不仅是介绍实现的方法,将实现过程中遇到的问题也都分享出来了,需要的朋友们下面来一起看看吧。

BALM2深度解析 | 港大MARS实验室如何用点簇革新激光BA?

本文深度解析了港大MARS实验室提出的BALM2方案如何通过点簇技术革新激光BA(Bundle Adjustment)处理。BALM2将点云数据聚合为点簇,显著提升计算效率,实测显示其计算耗时仅为传统方法的1/20。文章详细介绍了点簇的核心原理、二阶优化方法及与传统方法的性能对比,展示了其在激光SLAM领域的突破性应用。

weixin_29212867的博客 152

iOS开发日记1-tableview编辑

今天博主有一个tableview编辑的需求,遇到了一些困难点,在此和大家分享,能够共同进步. tableview的编辑是通过[self.tableview setEditing: BOOL1 animotion: BOOL2];进入的,如果需要进入编辑模式,则调用方法,将BOOL1改为YES.如果要退出编辑模式,则调用方法,将BOOL1改为NO.BOOL2为是否使用动画. 如果你想将编辑这个b...

weixin_30535913的博客 136

告别信息过载:我是如何用Feedly RSS阅读器打造个人专属信息流的(附Chrome插件使用技巧)

本文分享了如何利用Feedly RSS阅读器有效管理信息过载,打造个人专属信息流的方法。通过科学组织订阅源、智能过滤和跨平台同步技巧,帮助用户从被动接收转为主动筛选,提升信息获取效率。特别推荐使用Feedly的Chrome插件和AI过滤功能,实现高效的信息管理。

weixin_42526015的博客 354

使用TableView自带的多选功能

一、简单实现1.设置tableView属性self.tableView.allowsMultipleSelectionDuringEditing = YES; 2.然后在编辑按钮显示tableView编辑状态[self.tableView setEditing:YES animated:YES]; 3.查看被选中cell的indexPath数组NSArray *indexs = self.tabl...

4421

WPS接入DeepSeek,实现AI辅助功能

总的来说,借助 WPS 中宏功能与 DeepSeek 大模型的结合,文档处理、内容创作和数据分析等任务都能更加智能化、自动化。这不仅大幅提升了工作效率,也为办公场景带来了全新的智能化办公体验。

运维老生常谈 3803

二、基于C语言的JPEG解码代码详解

// JPEG解码 // 输入JPEG后输出Bitmap #include <stdio.h> #include <stdlib.h> #pragma warning(disable : 4996) unsigned int BuffIndex; // JPEG数据的位置 unsigned int BuffSize; // JPEG数据的大小 unsigned int BuffX; // 图像的横向尺寸 unsigned int BuffY; //

m0_37633745的博客 4451

ios 编辑UITableView (添加数据 删除数据)

1 实现uitablview 代理方法 2 commitEditingStyle 实现后 可初步右滑删除 及添加删除代码 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *...

a136447572的专栏 1638

群辉NAS映射为本地盘符

鼠标右击网络→映射网络驱动器→以上适合通过局域网操作,采用ZeroTier组网后,也可以按照以上步骤实现,这时使用 “虚拟局域网”的IP地址。

dgnankai的专栏 5772

tableView编辑

tableView编辑 tableView编辑的步骤 1.创建按钮, 用于触发编辑 2.指定哪些可以进行编辑(dataSource方法, 可选) 3.指定编辑样式(删除或添加, delegate的方法, 可选, 默认删除) 4.编辑完成方法中, 进行删除或添加(dataSource的方法, 先删数据, 再删cell) ...

weixin_30379531的博客 206

【人工智能】拒绝焦虑,理性突围:AI 时代 Java 工程师的职业重构与进化指南

摘要:在AI技术快速发展的背景下,Java工程师面临职业转型挑战。本文通过MECE原则解构工作内容,划分高替代风险区(如CRUD开发)、高增效潜能区(如逻辑优化)和高核心壁垒区(如架构设计),指出AI对不同任务的影响程度。从劳动经济学视角分析行业将呈现K型分化,初级执行者被替代,而精通AI协作的全栈工程师需求增长。文章强调警惕过度依赖AI导致认知能力退化,并提出转型路径:掌握AI驱动开发(AIDD)、深耕领域驱动设计(DDD)、拓展全流程能力及AI原生应用开发。最终结论指出,未来的核心竞争力在于结合AI工具

奶爸的编程之路,也就一周冷个三天 131

基于YOLOv26的道路抛洒物检测系统原理实现

本文提出了一种基于YOLOv26的道路抛洒物智能检测系统,通过深度学习技术实现道路抛洒物的实时检测与分类。系统采用分层架构设计,包含视频采集、目标检测、分类评估和预警处理等模块,能够自动识别轮胎碎片、货物包装、金属零件等多种抛洒物,并根据危险程度分级预警。YOLOv26算法在检测精度和速度上的优势使其特别适合道路监控场景,结合背景建模和运动目标提取技术,有效提高了复杂道路环境下抛洒物的识别率。该系统可集成到现有智能交通监控平台,为道路安全管理提供实时决策支持。

一键难忘的博客 1252

ios UITableView editing 编辑状态

https://www.jianshu.com/p/f65ca53fc9ba - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 该方法支持tableview cell侧滑删除或者增加,只支持单个操作...

georgehenrywilliam的博客 2342

【HYSPLIT 教程第二期】Inline WRF-HYSPLIT 耦合

【HYSPLIT 教程第二期】Inline WRF-HYSPLIT 耦合

WW、forever的博客 808

iOS开发系列 ---- UI (TableView的编辑和多项删除操作)

增加、删除和移动效果图: 实现核心代码:#import "ViewController.h"@interface ViewController ()< UITableViewDataSource, UITableViewDelegate>@property (nonatomic, strong) NSMutableArray *arrayDS; @property (nonatomic, stro

程序员小咖的博客 3501

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

设置TableView可编辑

设置TableView可编辑  (2011-01-19 09:00:53) 转载 关键词:对tableView进行增、删操作 1.设置tableView可编辑 RootViewController.m [self.navigationItem setRightBarButtonItem:[self editButtonItem]]; -

ch_soft的专栏 1万+

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

ios中tableview的移动添加删除

// // MJViewController.m // UITableView-编辑模式 // // Created by mj on 13-4-11. // Copyright (c) 2013年 itcast. All rights reserved. // #import "MJViewController.h" @interface MJViewCont...

weixin_34408717的博客 188

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

iOS学习笔记-029.UITableView的编辑模式

UITableView的编辑模式 一编辑模式叙述 二删除或添加行 步骤 删除的的方法 添加的方法 提交编辑模式的方法 三移动 步骤 移动处理的方法 四四种刷新表格数据的方法 五代码 六图示UITableView的编辑模式一、编辑模式叙述UITableView有个editing属性,当设置为 YES 时,可以进入编辑模式。 在编辑模式下,可以管理表格中的行,比如改变行的排列顺序、增加行、 删除行,

qiwenmingshiwo的专栏 762

iOS tableView左滑删除和编辑实现

//左滑删除 和编辑 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } - (NSArray&lt;UITableViewRowAction *&gt; *)tableView:(UITableView *)tableVie...

C_philadd的博客 3016

ios tableview 插入删除

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{     return UITableViewCellEditingStyleDelete; } -(void)tableV

zuojinmin的博客 620

关于tableview 编辑下多选择处理

1.设置可以多选择(并且设置tintColor 可以改变右侧 符号颜色)   self.tableView.allowsMultipleSelectionDuringEditing = YES;   self.tableView.tintColor = MAIN_THEME_GREEN_COLOR; 效果图: 2.定义下面修改状态的toolView   

zhanglizhi111的博客 902

tableview 编辑状态下,UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert 多选的时候,替换圆圈图片

版权声明:本文为博主原创文章,未经博主允许不得转载。 打开编辑模式,使得tableview处于选择状态 [html] view plain copy [_tableView setEditing:YES animated:NO]   [html] view plain copy

he317165264的博客 1562
上一篇: iOS疯狂详解之录制音频转换成Mp3
下一篇: iOS疯狂详解之开源库
吊炸天-狂人
博客等级 码龄12年 87粉丝 42原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值