zoukankan      html  css  js  c++  java
  • 第三章 点击单元格

    本项目是《beginning iOS8 programming with swift》中的项目学习笔记==》全部笔记目录

    ------------------------------------------------------------------------------------------------------------------

    实现点击cell弹出alertController

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        let alert = UIAlertController(title: nil, message: "What do you want to do?", preferredStyle: .ActionSheet)
        
        // 取消项
        let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
       
        // 打电话项
        let callAction = UIAlertAction(title: "Call " + "123-000-(indexPath.row)", style: .Default) { (action) -> Void in
            let alertMessage = UIAlertController(title: "Service unavailable", message: "Sorry, the call feature is unavailable yet.", preferredStyle: .Alert)
           
            let okAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
            alertMessage.addAction(okAction)
            self.presentViewController(alertMessage, animated: true, completion: nil)
        }
       
        // 是否来过
        let isVisitedAction = UIAlertAction(title: "I've been here", style: .Default) { (action) -> Void in
            let cell = tableView.cellForRowAtIndexPath(indexPath)
            cell?.accessoryType = .Checkmark
        }
       
       
        alert.addAction(cancelAction)
        alert.addAction(callAction)
        alert.addAction(isVisitedAction)
       
        self.presentViewController(alert, animated: true, completion: nil)
    }

    效果图:

    问题及提高:

    1. 现在check了一个cell后,滚动TableView,由于单元格复用,Check会乱掉。提示:使用一个[Bool]数组成员变量记录是否需要check,可以解决。

    2. 使用心形图标替换checkmark。 提示:iconImageView.hidden = false 

  • 相关阅读:
    显示AVI的第一桢
    视频采集,存成avi
    视频捕获
    如何将Wav文件做到EXE文件里
    图形整体拉出效果
    3.2 指数型生成函数
    3.1 普通型生成函数
    诡异的楼梯 HDU
    A strange lift HDU
    胜利大逃亡 HDU
  • 原文地址:https://www.cnblogs.com/tangzhengyue/p/4303495.html
Copyright © 2011-2022 走看看