现有代码:
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)
我不知道如何通过此代码添加正文请求.请帮我解决这个问题.
我在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的每个单元格中添加动作,还要显示单元格的名称.如果有人知道,请帮助我.
我有一个带有四个选项卡的 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。我该如何解决这个问题?
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)
此代码并未禁用在单元格中滑动。但是当滑动时会出现单元格删除选项。请任何人都可以帮助解决这个问题。