私はObjective-Cの開発にかなり慣れていません。ゼロから作成した最初のアプリでは、時間の経過とともにサイズが大きくなる円を描きたいと思います。問題は、画面上で円を移動できたのに、プロパティを更新できないように見えるため、円が大きくなったり小さくなったりすることです。
物事は次のようになります:
CCircle class
@interface CCircle : CShapes
@property float radius;
@property float startAngleRadians;
@property float endAngleRadians;
最初のビューコントローラ(ShapesViewController.m):
- (void) viewDidLoad
{
(...)
CCircle* circle = [[CCircle alloc] initWithFrame:frame];
circle.radius = 40;
circle.startAngleRadians = M_PI;
circle.endAngleRadians = 2*M_PI;
circle.tag = 1;
[self.view addSubView:circle];
//I also schedule an update method, so that it is called every 1 seconds.
[NSTimer scheduledTimerWithTmieInterval:1.0 target:self selector:@selector(updateCircle) userInfo:nil repeats:YES];
}
また、ShapesViewController.mでは、更新メソッドは次のとおりです。
- (void) updateCircle
{
CCircle *circle = [self.view viewWithTag:1];
//Now here: if I do this: the circle will "move" through the screen
CGRect frame = circle.frame;
frame.origin.x += 5;
[circle setFrame:frame];
//However, if I try to change the circle properties, I don't know what to do so
//that affects the circle. In this case, the circle will move through the screen,
//but I keep seeing always the same size(radius).
circle.radius += 5;
//I've tried the following (of course, not all at the same time):
//[self.vew addSubview:circle];
//[self.view sendSubviewToBack:circle];
//[self.view sendSubviewToFront:circle];
//[self.view setNeedsDisplay];
//[self.view setNeedsLayout];
}
私が間違っていること、そして私が望むことを達成するために私は何をすべきかについての助けはありますか?
ありがとう!