开发者

PresentModalViewController or addsubview?

开发者 https://www.devze.com 2023-01-05 11:42 出处:网络
Hi I am writing an app in xcode 3.2.3. All I want to do is switch to another view but I am unsure of the best way to do this. I can do it either of these 2 ways...

Hi I am writing an app in xcode 3.2.3. All I want to do is switch to another view but I am unsure of the best way to do this. I can do it either of these 2 ways...

PreferencesViewController *screen = [[PreferencesViewController alloc]initWithNibName:nil bundle:nil];

screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentModalViewController:screen animated:YES];

[screen release];

or using...

PreferencesViewCont开发者_高级运维roller *screen = [[PreferencesViewController alloc]initWithNibName:nil bundle:nil];

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:1.0];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];

[self.view addSubview:screen.view]; 

[UIView commitAnimations];

I have some problems with both of these methods. If I use presentModalViewController and I simulate a memory warning in the PreferencesViewController my app crashes. This is not the case with the second method. The second method however makes my buttons looks strange during the flipping animation.

Can someone tell me what is wrong and/or advise me on which method is right.

Thanks


You can try to do this, don't forget to release:

[self.navigationController pushViewController:[[YourViewController alloc]    initWithNibName:nil bundle:nil] animated:YES];   


PresentModalViewController:-

YourViewController *vC = [YourViewController alloc]initWithNibName:@"YourViewController" bundle:nil];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:vC animated:YES];
[vC release];

This is working fine for me

Try this code.All the best

0

精彩评论

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