我正在尝试从网址中提取图片时显示加载视图。我知道如何使用UIWebview
执行此操作但是,我无法使用UIImageView
或MPMoviePlayerController
找到实现此目的的方法。
要从Url加载图片或视频,请使用:
let pictureURL = NSURL(string: pictureToDisplay!)
newsImage.hnk_setImageFromURL(pictureURL!)
或
let videoURL = NSURL(string: sourceToDisplay!)
moviePlayer = MPMoviePlayerController(contentURL: videoURL!)
有没有办法在加载网址时显示和隐藏加载视图loading_view.hidden = false
- loading_view.hidden = true
?
答案 0 :(得分:0)
使用NSURLConnectionDelegate
解决。
func requestNSURLconnection(url: NSURL){
let request: NSURLRequest = NSURLRequest(URL: url)
let connection: NSURLConnection = NSURLConnection(request: request, delegate: self, startImmediately: true)!
connection.start()
}
func connectionDidFinishLoading(connection: NSURLConnection!)
{
print("finishedLoading")
}