【发布时间】:2021-04-23 18:29:02
【问题描述】:
I will use GCD to run tasks that will in turn send tasks, that use wrist_band_UIImageView, to GCD main to display.
IE.
1. ViewController starts backend task onto DispatchQueue.global which is an endless loop
2. this endless loop periodically needs to update the UIImageView and so puts a task onto main queue to update the UIImageView.
class ViewController: UIViewController { <<<<<< E R R O R Class 'ViewController' has no initializers
@IBOutlet weak var app_title: UILabel!
//////////////////////// VARIABLES ////////////////////////////
var wrist_band_UIImageView: UIImageView
override func viewDidLoad() ///////////////////////////////////////// VIEW DID LOAD
{
print("viewDidLoad...")
super.viewDidLoad()
// Init data:
let image = UIImage(systemName: "applewatch")
self.wrist_band_UIImageView = UIImageView(image: image!)
print("viewDidLoad starts run_app.")
DispatchQueue.global().async{ app_class.run_app() }
print("viewDidLoad done.")
return
}
}
更新:
我将 UIImageView 从静态更改为实例,现在类行生成错误“类 'ViewController' 没有初始化程序”。
【问题讨论】:
-
你的问题真的没有意义。为什么会有一个
UIImageView的静态变量?UIImageView属于单个视图层次结构。这是安装在应用主屏幕上的图像视图还是其他什么? -
您所说的“......发送使用手腕带_UIImageView的任务到GCD主显示是什么意思?”
-
已将静态更改为实例,但现在在类行出现错误:类 'ViewController' 没有初始化程序
标签: ios swift xcode uiimageview