0
我試圖將圖像提供給使用Swift 3編寫的iOS應用程序。我可以直接從它的URL加載圖像,但是因爲圖像沒有HTTPS ,我不得不在PHP中編寫一個包裝器,可以獲取圖像並通過HTTPS保留它。我使用CakePHP來處理工作正常的圖像,但iOS應用程序不顯示圖像。正在檢索圖像,但不會顯示在UIImageView中。任何幫助表示讚賞。使用PHP和Swift將圖像提供給iOS應用程序
斯威夫特3
let mugshotParams: [String:Any] = [
"action":"632",
"params":[
"offender_id":"\(self.delegate.predators[index].id)"
]
]
do {
let mugshotObject = try JSONSerialization.data(withJSONObject: mugshotParams, options:[])
let request = NSMutableURLRequest(url: URL(string: delegate.urlMobile! as String)!, cachePolicy:NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData, timeoutInterval: 30)
request.httpBody = mugshotObject
request.httpMethod = "POST"
let task = URLSession.shared.dataTask(with: request as URLRequest, completionHandler: {data, response, error in
DispatchQueue.main.sync {
infoWindow.imageMugshot.image = UIImage(data: data!)
infoWindow.imageMugshot.contentMode = .scaleAspectFit
}
})
task.resume()
} catch {
}
CakePHP的
private function getPredatorMugshot() {
$image = file_get_contents('http://domain.com/predator/image.jpg');
$this->response->type('jpg');
$this->response->body($image);
}
問題開始1月1日,蘋果公司將不接受有例外的應用程序傳輸安全性或設置應用傳輸安全性爲false /沒有任何應用程序,所以這是不行的。 – recoilnetworks