2016-01-27 31 views
1

我试图在我的第一个控制器的WK状态栏中自定义标题。在WK状态栏中自定义标题

enter image description here

正确的方法应该是这样的:

public func setTitle(title: String?) // title of controller. displayed when controller active 

所以

WKInterfaceController.setTitle("my Title") 

但使用此代码,Xcode中说:Cannot convert value of type 'String' to expected argument type 'WKInterfaceController'。怎么了?

回答

1

setTitle是一个实例方法,而不是一个类方法。

您需要引用特定的实例控制器来更改该控制器的标题。由于您一般会在自己的代码中设置您的第一个控制器的标题,您可以省略自己,并且只需致电

setTitle("my Title")