编辑UITableviewCell--Editing
self.navigationItem.rightBarButtonItem = self.editButtonItem;
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
[self.countriesTableView setEditing:editing animated:animated];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
Country * delegateCountry = self.countries[indexPath.row];
[self.countries removeObject:delegateCountry]; [self.countriesTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
insert(默认编辑样式都是UITableviewCellEditingStyleDelete),所以添加insert样式。
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ((indexPath.row%) == ) {
return UITableViewCellEditingStyleInsert;
}
return UITableViewCellEditingStyleDelete;
}
}else if (editingStyle == UITableViewCellEditingStyleInsert){
Country * copiedCountry = self.countries[indexPath.row];
Country * newCountry = [[Country alloc] init];
newCountry.name = copiedCountry.name;
newCountry.flag = copiedCountry.flag;
newCountry.capital = copiedCountry.capital;
newCountry.motto = copiedCountry.motto;
[self.countries insertObject:newCountry atIndex:indexPath.row+];
[self.countriesTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:indexPath.row + inSection:indexPath.section]] withRowAnimation:UITableViewRowAnimationRight];
}
重新排序
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
[self.countries exchangeObjectAtIndex:sourceIndexPath.row withObjectAtIndex:destinationIndexPath.row];
[self.countriesTableView reloadData];
}
编辑UITableviewCell--Editing的更多相关文章
- TableEdit UI_10
1.tableView的编辑的步骤: 1.让tableView处于编辑状态,(默认所有的cell都处于编辑状态,默认下的编辑样式是删除) 2.设置哪些cell可以编辑 3.设置编辑的样式(删除,插 ...
- UITableView使用指南
本文转载至 http://blog.csdn.net/yu0089/article/details/8227402 一.概述 UITableView是iOS开发比不可少也是最重要的一个控件类.可以说任 ...
- UI:数据库练习、滤镜效果
相机处理滤镜效果 滤镜主要使用在相机的美颜. #import "ViewController.h" #import "ImageUtil.h" #import ...
- UITableView总结
.协议介绍 UITableViewDataSource() UITableViewDelegate(常用) .刷新 下拉刷新: 上拉刷新 .搜索 .重用 自定义cell 不使用重用方法 注册Cell ...
- Sublime Text 全程指引 by Lucida
作者:Lucida 微博:@peng_gong 豆瓣:@figure9 博客园:@figure9 原文链接:http://zh.lucida.me/blog/sublime-text-complete ...
- 成吨提高开发效率:Intellij Shortcuts精简子集与思维模式
在线精简cheatsheet备查表:intellij.linesh.twGithub项目:intellij-mac-frequent-keymap Intellij的快捷键多而繁杂,从官方推荐的key ...
- pycharm快捷键及一些常用设置
pycharm快捷键及一些常用设置,有需要的朋友可以参考下. Alt+Enter 自动添加包 Ctrl+t SVN更新 Ctrl+k SVN提交 Ctrl + / 注释(取消注释)选择的行 Ctrl+ ...
- PyCharm3.0默认快捷键(翻译的)
PyCharm3.0默认快捷键(翻译的) PyCharm Default Keymap 1.编辑(Editing) Ctrl + Space 基本的代码完成(类.方法.属性)Ctrl + Alt ...
- pycharm快捷键、常用设置、包管理
pycharm快捷键.常用设置.包管理 在PyCharm安装目录 /opt/pycharm-3.4.1/help目录下可以找到ReferenceCard.pdf快捷键英文版说明 or 打开pychar ...
- Pycharm快捷方式
PYCHARM的快捷方式 PyCharm3.0默认快捷键(翻译的)1.编辑(Editing)Ctrl + Space 基本的代码完成(类.方法.属性)Ctrl + Alt + Space 快速导入任意 ...
随机推荐
- [译]GotW #3: Using the Standard Library (or, Temporaries Revisited)
高效的代码重用是良好的软件工程中重要的一部分.为了演示如何更好地通过使用标准库算法而不是手工编写,我们再次考虑先前的问题.演示通过简单利用标准库中已有的算法来避免的一些问题. Problem JG Q ...
- hdu3006之位压缩
The Number of set Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- js中replace用法
js中replace的用法 replace方法的语法是:stringObj.replace(rgExp, replaceText) 其中stringObj是字符串(string),reExp可以是正则 ...
- java数组或集合返回空的问题
在有返回值的情况下,平时我写代码基本遇到错误什么都是返回null,我因为我觉得把数组或集合这个初始化占空间. 但是我发现这样在每次客户段调用都要进行非空判断,而且有时调用内置api还容易报错误,于是解 ...
- java web路径的问题
对于<form action="/xx"> 和 <a href='/xx'> 其中,xx相应的为网站根目录 一般网站为虚拟目录,所以要 写成 /web应 ...
- IPv6 tutorial 3 New features: IPsec and LAN features
https://4sysops.com/archives/ipv6-tutorial-part-3-new-features-ipsec-and-lan-features/ In the last p ...
- Android开发UI之Fragment-Tabbed Activity的使用
使用ADT新建的时候,可以选择Tabbed Activity,选择新建一个工程. 新建的工程中,选择不同的Tab页显示不同的内容,主要是通过SectionsPagerAdapter类中的Fragmen ...
- Nginx+Keepalived 做负载均衡器
1.安装 keepalived 1 2 3 4 5 6 7 8 9 tar zxvf keepalived-XXXX.tar.gz ./configure --prefix=/usr/local/ ...
- 1.进入debug模式(基础知识列表)
1.进入debug模式(基础知识列表)1.设置断点 2.启动servers端的debug模式 3.运行程序,在后台遇到断点时,进入debug调试状态 ========================= ...
- java.lang.IllegalStateException: Required view 'text1' with ID 2131492943 for field 'mText' was not found. If this view is optional add '@Nullable' annotation
使用ButterKnife 8.2的时候遇到这个问题 很明显空指针问题 按照提示添加 import android.support.annotation.Nullable;@Nullable 造成原 ...