我有一个 UIViewControllerGamePlayViewController
和一个 UIView JoystickView
。
我试图将浮点值设置为JoystickView
.
在GamePlayViewController.m
JoystickView *joystick = [[JoystickView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
joystick.velocity = 123.0f;
[self.view addSubview:joystick];
在JoystickView.h
@property(nonatomic) float velocity;
.m
@synthesize velocity;
-(id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
NSLog(@"%f", velocity); //output is 0
}
return self;
}
我错过了什么?