在 alamofire 4 中,我使用此代码禁用服务器评估:
private var Manager : Alamofire.Session = {
// Create the server trust policies
let serverTrustPolicies: [String: ServerTrustPolicy] = ["serverurl.com": .disableEvaluation]
// Create custom manager
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = Alamofire.Session.defaultHTTPHeaders
let man = Alamofire.Session(
configuration: URLSessionConfiguration.default,
serverTrustPolicyManager: ServerTrustManager(policies: serverTrustPolicies)
)
return man
}()
Run Code Online (Sandbox Code Playgroud)
但是在带有swift 5 xcode 10.2的alamofire 5中不再工作,我收到了这个错误。
使用未声明的类型 'ServerTrustPolicy' 类型 'Session' 没有成员 'defaultHTTPHeaders'
但我找不到一种新的方法来使用 alamofire 5 进行这项工作。
我有一个在全屏上显示弹出式窗口的按钮,主视图有6个自定义视图,其中有5个按钮带有灰色或蓝色的色调,具体取决于某些参数。但是当弹出窗口出现时,海关视图内的按钮变为灰色,一旦弹出窗口不显示自定义视图为淡色,我想避免在出现弹出窗口时按钮色调不会改变。自定义视图是uitableviewCell内部的视图。自定义视图就是这样定义的。
class ratingDoors: UIView {
var rating: Int = 0{
didSet{
makeRating()
}
}
@IBOutlet var contentView: UIView!
@IBOutlet weak var button1: UIButton!
@IBOutlet weak var button2: UIButton!
@IBOutlet weak var button3: UIButton!
@IBOutlet weak var button4: UIButton!
@IBOutlet weak var button5: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
//fatalError("init(coder:) has not been implemented")
}
private func commonInit() {
//TODO: Do some stuff
// 1. Load the nib
Bundle.main.loadNibNamed("ratingDoors", owner: …Run Code Online (Sandbox Code Playgroud)