【发布时间】:2014-08-24 17:41:26
【问题描述】:
我在创建函数“touchesBegan”然后创建一个 UIPoint 和 UITouch 常量或变量来保存 x 和 y 坐标时遇到问题。我在 Objective-C 中有我想要的确切代码,但我不知道它在 Swift 中的等价物是什么。这是我想基本上翻译成 Swift 代码的 Objective-C 代码... 注意:这是一个单视图应用程序,而不是游戏...提前致谢。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:self.view];
if (point.x < 160) {
var = 10;
}
else{
var = 20;
}
}
【问题讨论】:
标签: ios objective-c xcode swift touchesbegan