用if语句引起麻烦||

Fab*_*oni 0 c iphone if-statement objective-c

我正在研究一个新的项目,我正在用简单的坐标工作:

if (locationOnJoystick.x > joystickArea.frame.size || locationOnJoystick.y > joystickArea.frame.size) {
Run Code Online (Sandbox Code Playgroud)

但是在运行代码时我得到了一个错误:

错误:无效操作数到二进制>(有'CGFloat'和'CGSize')

谁能看到解决方案?!

真诚地,mavrick3.

peo*_*oro 6

locationOnJoystick.x是一个CGFloat,而joystickArea.frame.size一个是CGSize.它们是不同的类型,你无法比较它们.

我想你应该locationOnJoystick.x与你的宽度joystickArea.frame.size(和y和身高相同)进行比较:

if (locationOnJoystick.x > joystickArea.frame.size.width || locationOnJoystick.y > joystickArea.frame.size.height) {
Run Code Online (Sandbox Code Playgroud)