小编Kus*_*tha的帖子

如何使用Alamofire 4在Swift 3中为JSON数据发送带有参数和正文的POST请求?

Postman api url在下面添加. 在此输入图像描述

现有代码:

let baseUrl = "abc.com/search/"
let param  =  [
        "page":"1",
        "size":"5",
        "sortBy":"profile_locality"
    ]

    let headers = [
        "Content-Type": "application/json"
    ]


    Alamofire.SessionManager.default.request("\(baseUrl)field", method: .post,parameters: param, encoding: JSONEncoding.default, headers: headers).responseJSON { response in
        print(response.request ?? "no request")  // original URL request
        if(response.response?.statusCode != nil){
            print("done")
            if self.checkResponse(response.response!.statusCode){
                let json = JSON(data: response.data!)
                //print("at_LeadStop json \(json)")
                return completionHandler(json, false)

            } else {
                return completionHandler(JSON.null, true)
            }
        } else {
            print("gone")
            return completionHandler(JSON.null, true)
        }}
Run Code Online (Sandbox Code Playgroud)

我不知道如何通过此代码添加正文请求.请帮我解决这个问题.

json ios alamofire swift3

9
推荐指数
1
解决办法
1万
查看次数

在哪些函数中,如何在LiquidFloatingActionButton的索引单元格中添加动作?

我在LiduidFloatingActionButton中创建了两个按钮单元,代码如下.

private func createFloatingButtons(){
    cells.append(createButtonCell("firstCell"))
    cells.append(createButtonCell("secondCell"))
    let floatingFrame = CGRect(x: self.view.frame.width - 56 - 16, y: self.view.frame.height - 56 - 36, width: 56, height: 56)
    let floatingButton = createButton(floatingFrame, style:.Up)
    self.view.addSubview(floatingButton)
    self.floatingActionButton = floatingButton
}
Run Code Online (Sandbox Code Playgroud)

我不知道在LiquidFloatingActionButton的每个单元格中添加动作,还要显示单元格的名称.如果有人知道,请帮助我.

ios swift

5
推荐指数
1
解决办法
79
查看次数

清除视图控制器的导航堆栈

我有一个带有四个选项卡的 tabBarController。在每个选项卡中,我可以浏览一系列视图控制器。在最后一个视图控制器上,我有一个“完成”按钮,单击该按钮我必须重定向到我的初始 tabBarController。我当前用于执行此操作的代码如下(单击按钮时)。

let storyboard = UIStoryboard.init(name: "Main", bundle: Bundle.main)
if let tabViewController = storyboard.instantiateViewController(withIdentifier: "TabBarController") as? UITabBarController {
    self.navigationController!.pushViewController(tabViewController, animated: false)
}
Run Code Online (Sandbox Code Playgroud)

但我觉得这不是正确的方法,因为导航堆栈不断添加。相反,我想清除导航堆栈并显示堆栈中的第一个 tabBarController。我该如何解决这个问题?

tabbarcontroller ios swift

3
推荐指数
1
解决办法
6878
查看次数

如果条件在 swift 中为 false,则禁用在 tableView 中滑动单元格?

override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {

    if condition == true {
    let pause = UITableViewRowAction(style: .Destructive, title: "pause") { action, index in
            print("pause button tapped")
            return [pause]
        }
    } else {

        return .None
    }
}
Run Code Online (Sandbox Code Playgroud)

此代码并未禁用在单元格中滑动。但是当滑动时会出现单元格删除选项。请任何人都可以帮助解决这个问题。

uitableview swipe swift

2
推荐指数
1
解决办法
1285
查看次数

标签 统计

ios ×3

swift ×3

alamofire ×1

json ×1

swift3 ×1

swipe ×1

tabbarcontroller ×1

uitableview ×1