swift-tableView 删除行
来源:互联网 发布:淘宝上购物车图片卡通 编辑:程序博客网 时间:2024/05/24 00:49
import UIKitclass FirstViewController: UIViewController { @IBOutlet weak var tableView: UITableView! let cellIdentified = "cell" var numbers = ["One","Two","Three","Foure","Five","Six","Seven","Eight","Nine","Ten"]; override func viewDidLoad() { super.viewDidLoad() // 准备UI prepareUI() // Do any additional setup after loading the view. } private func prepareUI() { navigationItem.title = "首页" tableView.delegate = self tableView.dataSource = self tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: cellIdentified) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { if editingStyle == UITableViewCellEditingStyle.Delete { numbers.removeAtIndex(indexPath.row) tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic) } } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { // Get the new view controller using segue.destinationViewController. // Pass the selected object to the new view controller. } */ }extension FirstViewController:UITableViewDelegate, UITableViewDataSource { func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentified, forIndexPath: indexPath) cell.textLabel?.text = numbers[indexPath.row] return cell } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return numbers.count } }
0 0
- swift-tableView 删除行
- tableview之多行删除
- ios tableView删除行
- swift- 去除tableView 多余行
- swift-tableView 代理方法实现点击按钮删除效果
- Swift 关于tableView的多选和删除
- ios TableView那些事3(Swift 三) TableView 的删除操作
- swift 去除tableView 多余行的方法
- swift tableview中添加侧滑删除功能 类似qq删除
- swift入门之TableView
- iOS TableView 使用(swift)
- swift- tableView 的使用
- swift创建tableview
- Swift 创建一个tableview
- swift tableView deleteRowsAtIndexPaths
- Swift - TableView
- ios swift tableview
- swift+tableview+数据展示
- C# 读取 Oracle 数据库表的例子
- springmvc配置事务要点
- 打开eclipse时 提示 D:\eworkplace\appcompat_v7\res\values-v23\styles_base.xml:20: error: Error retrieving
- 2016年目标清单
- 引导页之SharedPreferences的使用
- swift-tableView 删除行
- Leetcode 280: Wiggle Sort
- hi
- Facebook SDK集成之纲要篇
- Hdu 5595 GTW likes math
- Xshell
- 常见数据类型转换
- gcc 连接不上stl
- 适配器