如何在 Swift 的 iOS 设置中创建类似的选择选项 UITableView? [英] How to create selecting option UITableView similar in iOS Settings in Swift?

查看:24
本文介绍了如何在 Swift 的 iOS 设置中创建类似的选择选项 UITableView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款应用,要求用户从表格视图列表中选择一个选项.它有点类似于 iPhone 设置中的铃声选项.我附上了一个屏幕插图,说明我正在努力完成什么.

I'm developing an app that requires users to select one option from the list of the table view. It's kind of similar to ringtone option in settings of the iPhone. I have attached a screen illustration of what exactly I'm trying to accomplish.

现在我希望被选中的选项能够作为一个值发送到我的 PHP 脚本中,使用 HTTPMethod.我猜这是我使用的请求类型,只是将数据存储在变量中.

Now I want that option that is selected to be able to send as a value to my PHP Script with HTTPMethod. This is the type of request I use, I guess, is just in matter of storing the data in variable.

HTTP 请求演示

   let requestURL = NSURL(string: "http://example.com/script.php")
   let request = NSMutableURLRequest(URL: requestURL!)
   request.HTTPMethod = "POST"

插图:

我知道这是一个初学者,但我还没有找到任何可以快速完成此操作的教程.

I understand this is a beginner, but I haven't found any tutorial that does this in swift.

推荐答案

这一切都可以使用 segue 来完成

All this can be done using segue

  1. 你只需要点击tableview中的一个按钮或一个单元格就可以转到下一个viewController.你可以使用show segue
  2. 使用选择单元格时,触发 unwind segue 返回.并使用 unwind segue 将数据传回.
  3. 使用传回的数据更新模型和 UI.
  1. You just need to click a button or a cell in tableview to go to next viewController.You can use show segue
  2. When use select the cell,fire an unwind segue to go back. And use the unwind segue to pass data back.
  3. Update model and UI with the data passed back.

这篇关于如何在 Swift 的 iOS 设置中创建类似的选择选项 UITableView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆