加载视图后隐藏子视图图像(使用 Swift)
Hide subview image once the view has loaded (using Swift)
技术:XCode6、iOS 8.2、Swift
加载视图时,我添加了一张图片:
override func viewDidLoad() {
super.viewDidLoad()
webView.delegate = self
self.navigationController?.toolbarHidden = false;
openLoadingPopup()
if browserHistory.count < 1 {
backButton.enabled = false
}
let imageName = UIImage(named: "image.png")
let imageview = UIImageView(image: imageName)
imageview.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)
self.view.addSubview(imageview)
}
我想在此处删除该图像(如果可能)。最好的方法是什么?
func webViewDidFinishLoad(webView: UIWebView) {
UIApplication.sharedApplication()
. networkActivityIndicatorVisible = false
closeLoadingPopup()
if cacheURL {
++browserHistoryIndex
browserHistory.insert(webView.request!.URL, atIndex: browserHistoryIndex)
backButton.enabled = browserHistoryIndex != 0
//forwardButton.enabled = browserHistoryIndex != browserHistory.count - 1
}
if webView.request!.URL == lastURL {
cacheURL = true
}
}
使 imageView 成为 属性 而不是局部变量,并在 webViewDidFinishLoad 方法中使用 imageView.removeFromSuperview()。
技术:XCode6、iOS 8.2、Swift
加载视图时,我添加了一张图片:
override func viewDidLoad() {
super.viewDidLoad()
webView.delegate = self
self.navigationController?.toolbarHidden = false;
openLoadingPopup()
if browserHistory.count < 1 {
backButton.enabled = false
}
let imageName = UIImage(named: "image.png")
let imageview = UIImageView(image: imageName)
imageview.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)
self.view.addSubview(imageview)
}
我想在此处删除该图像(如果可能)。最好的方法是什么?
func webViewDidFinishLoad(webView: UIWebView) {
UIApplication.sharedApplication()
. networkActivityIndicatorVisible = false
closeLoadingPopup()
if cacheURL {
++browserHistoryIndex
browserHistory.insert(webView.request!.URL, atIndex: browserHistoryIndex)
backButton.enabled = browserHistoryIndex != 0
//forwardButton.enabled = browserHistoryIndex != browserHistory.count - 1
}
if webView.request!.URL == lastURL {
cacheURL = true
}
}
使 imageView 成为 属性 而不是局部变量,并在 webViewDidFinishLoad 方法中使用 imageView.removeFromSuperview()。