斯威夫特&&愤怒。 设置控制器。

4.将方法添加到SettingsViewController。

  覆盖 func tableView( _ tableView:UITableView,didSelectRowAt indexPath:IndexPath){} 

5.接下来,我们将添加一些依赖于indexPath的操作

  覆盖 func tableView( _ tableView:UITableView,didSelectRowAt indexPath:IndexPath){ 
如果 indexPath.row == 1 {
} 如果 indexPath.row == 2 {}
}

6.首先,行动将是与我们联系。 就我而言,它将打开Instagram。

  如果  url = URL(字符串:“ https://www.instagram.com/curlnomad/”){ 
UIApplication.shared.open(URL,选项:[:])
}

7.接下来,我们将添加没有动作的简单AlertController

   alertController = UIAlertController(标题:“”,消息:“确定要注销”,preferredStyle:.alert) 
  let action1 = UIAlertAction(标题:“是”,样式:.default) 
action2 = UIAlertAction(标题:“取消”,样式:.cancel)
  alertController.addAction(action1) 
alertController.addAction(action2)
self .present(alertController,动画: true ,完成: nil

8.最后,您的函数将如下所示:

  覆盖 func tableView( _ tableView:UITableView,didSelectRowAt indexPath:IndexPath){ 
如果 indexPath.row == 1 {
如果 url = URL(字符串:“ https://www.instagram.com/curlnomad/”){
UIApplication.shared.open(URL,选项:[:])
}
} if indexPath.row == 2 {
alertController = UIAlertController(标题:“”,消息:“确定要注销”,preferredStyle:.alert)
  let action1 = UIAlertAction(标题:“是”,样式:.default) 
action2 = UIAlertAction(标题:“取消”,样式:.cancel)
  alertController.addAction(action1) 
alertController.addAction(action2)
self .present(alertController,动画: true ,完成: nil
}
}