开发者

uniimageview not updating after views tranistion

I have one main view where I display an image, in the method viewDidLoad:

ballRect = CGRectMake(posBallX, 144, 32.0f, 32.0f); theBall = [[UIImageView alloc] initWithFrame:ballRect]; [theBall setImage:[UIImage imageNamed:@"ball.png"]]; [self.view addSubview:theBall]; [laPalla release];

Obviously, the value of posBallX is defined and then update via a custom method call many times in the same class.

theBall.frame = CGRectMake(posBallX, 144, 32, 32);

Everything works, but when I go to another view with

[self presentModalViewController:viewTwo animated:YES];

and come back with

[self presentModalViewController:viewOne animated:YES];

the image is displayed correctly after the method viewDidLoad is called (I retrieve the values with NSUserDefaults) but no more in the second method. In the NSLog I can even see the new posBall开发者_如何学运维X updating correctly, but the Image is simply no more shown... The same happens with a Label as well, which should print the value of posBallX.

So, things are just not working if I come back to the viewOne from the viewTwo... Any idea???????

Thanks so much!


You should use dismissModalViewControllerAnimated: to switch back to viewOne from viewTwo instead of trying to present viewOne modally.

Also note that viewDidLoad is called only once - after the view controller's view is loaded into memory. If you want to perform an action once a view comes back on screen, you should do so in viewWillAppear:.

Both of these points are discussed in the UIViewController class reference and in the View Controller Programming Guide.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜