我有一些VC都是从BaseVC继承的:UIViewController。一些VC嵌入了tableView / collection视图,我正在创建一个函数,允许所有VC在表/集合/ UIView的中心创建一个活动指示器,其函数调用如
activityIndicatorBegin(mytableView)
activityIndicatorBegin(myCollectionView)
activityIndicatorBegin(nil)
以下是我的尝试,我得到的错误是一个奇怪的“未定义的架构x86_64符号”。所以我想这不是正确的方法
var activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView()
func activityIndicatorBegin(scrollView: UIScrollView?) {
if activityIndicator.isAnimating() == false {
activityIndicator = UIActivityIndicatorView(frame: CGRectMake(0,0,20,20))
activityIndicator.center.x = view.center.x
activityIndicator.center.y = view.center.y - 100
activityIndicator.hidesWhenStopped = true
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge
activityIndicator.color = UIColor.blackColor()
if let scrollView = scrollView {
scrollView.addSubview(activityIndicator)
} else {
view.addSubview(activityIndicator)
}
activityIndicator.startAnimating()
}
}
func activityIndicatorEnd() {
if activityIndicator.isAnimating() == true {
activityIndicator.stopAnimating()
activityIndicator.removeFromSuperview()
}
}
错误
Undefined symbols for architecture x86_64:
"myAPP.BaseViewController.activityIndicatorBegin (__ObjC.UITableView?) -> ()", referenced from:
_OBJC_CLASS_$__TtC7myAPP9VC1 in VC1.o
_OBJC_CLASS_$__TtC7myAPP14VC2 in VC2.o
_OBJC_CLASS_$__TtC7myAPPVC3 in VC3.o
_OBJC_CLASS_$__TtC7myAPP10VC4 in VC4.o
_OBJC_CLASS_$__TtC7myAPP10VC5 in VC5.o
_OBJC_CLASS_$__TtC7myAPP9VC6 in VC6.o
_OBJC_CLASS_$__TtC7myAPP6VC7 in VC7.o
注意我有多个VC正在调用此函数。一些是TableView,一些是标准的UIViewcontroller,一些是CollectionView