Ios Objective-c方法

Ios Objective-c方法,ios,objective-c,iphone,swift,Ios,Objective C,Iphone,Swift,我正在尝试将objective-c编写的代码转换为Swift语言。 以下几行: - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if (scrollView.contentOffset.y < self.mapView.frame.size.height*-1 ) { [scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, self

我正在尝试将objective-c编写的代码转换为Swift语言。 以下几行:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{

if (scrollView.contentOffset.y < self.mapView.frame.size.height*-1 ) {
    [scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x,   self.mapView.frame.size.height*-1)];

}
}
谁能告诉我这里发生了什么,这个表达式是如何计算为布尔值的?指针是我无法将它转换成Swift的东西,你能帮我怎么做吗

提前谢谢

self.mapView.frame.size.height * -1

这是一个乘法。

此错误的原因是表达式的运算符和对象之间没有空格

编译时,编译器将这行代码打断为self.mapView.frame.size.height*-1。它得到了什么
self.mapView.frame.size.height*
-1
。所以编译器在这里错误地理解为两个独立的参数

需要在
self.mapView.frame.size.height
*
之间的空格,以告诉编译器这是一个将
self.mapView.frame.size.height
-1
值相乘的表达式

因此,您的相关Swift代码如下:

func scrollViewDidScroll(scrollView: UIScrollView) {
    if (scrollView.contentOffset.y < self.mapView.frame.size.height * -1 ) {
        scrollView .setContentOffset(CGPointMake(scrollView.contentOffset.x, self.mapView.frame.size.height * -1), animated: true)
    }
}
func scrollViewDidScroll(scrollView:UIScrollView){
if(scrollView.contentOffset.y
不确定,当我在Swift中以这种形式粘贴它时,Xcode调用“调用中参数“动画”缺少参数”-我想如果它只是一个乘法,它不会引起任何问题。而且,它应该被评估为非常感谢你!我会尽快投你的票!
func scrollViewDidScroll(scrollView: UIScrollView) {
    if (scrollView.contentOffset.y < self.mapView.frame.size.height * -1 ) {
        scrollView .setContentOffset(CGPointMake(scrollView.contentOffset.x, self.mapView.frame.size.height * -1), animated: true)
    }
}