如何在表中制作@IBAction?

时间:2015-03-12 17:46:52

标签: ios uitableview swift call

我写了一个应用程序来拥有一张桌子,当我按下按钮时它会打个电话。我已经做了一个表,代码如下..

var callContent = ["Police","Hospital"]
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    return callContent.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
    let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Name")
    cell.textLabel?.text = callContent[indexPath.row]
    return cell
}

和我的通话功能

var url:NSURL = NSURL(string: "tel://0812742111")!
    UIApplication.sharedApplication().openURL(url)

现在我想从表中执行操作以连接我的调用函数。 你们可以提出建议吗?

1 个答案:

答案 0 :(得分:0)

听起来您似乎想要实施UITableViewDelegate didSelectRowAtIndexPath

Here is the Apple documentation for that class