我有点误解如何正确使用 - (void)。每当我尝试使用 - (Void)编写代码,但出现错误“Expected declaration
”或有时“Binary operator '-' cannot be applied to operands of type 'UIFont' and '(Void).Type'
”。如何解决Swift中的“预期声明”错误?
这是怎么发生的?在swift中正确使用此功能的正确方法是什么?
{
- (Void)keyboardWillShow { //>> showing me the error "Binary operator '-' cannot be applied to operands of type 'UIFont' and '(Void).Type'"
// Animate the current view out of the way
if (self.view.frame.origin.y >= 0)
{
[self setViewMovedUp:YES];
}
else if (self.view.frame.origin.y < 0)
{
[self setViewMovedUp:NO];
}
}
}
感谢
请通读了雨燕编程语言[Apple的文档(https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/index.html)。 –
用导致问题的实际代码更新您的问题。 – rmaddy
这是Objective-C代码,而不是Swift代码。请阅读[Swift编程语言](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/)书。 – rmaddy