2012-02-29 5 views
0

ボタンを押すたびにビューを切り替える基本的な2ビューアプリケーションを作成しました。初心者:マルチビューアプリケーションでビューが正しく切り替わらない

しかし、何らかの理由で私がシミュレータで実行すると、両方のビューは常にMainWindow.xibビューの上に数ピクセルあり、常にその上にあります。そして、奇妙なことは、私がビューを切り替えるときにアニメーションがないことです。

問題は何ですか?

これは私が私のAppDelegate.m

-(void)switchView:(UIView *)view1 toView:(UIView *)view2{ 

    [UIView beginAnimations:@"Animation" context:nil]; 
    [UIView setAnimationDuration:1.75]; 
    [UIView setAnimationTransition:UIViewAnimationOptionTransitionFlipFromLeft forView:self.window cache:YES]; 
    [view1 removeFromSuperview]; 
    [window addSubview:view2]; 
    [UIView commitAnimations]; 
} 

答えて

0

に持っているものこんにちは

-(void)switchView:(UIView *)view1 toView:(UIView *)view2 
    { 
     view2.frame = self.window.bounds; 
     [UIView beginAnimations:nil context:NULL]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDuration:0.5f]; 
     [UIView setAnimationBeginsFromCurrentState:YES]; 
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view2 cache:NO]; 
     [view1 removeFromSuperview]; 
     [window addSubview:view2]; 
     [UIView commitAnimations]; 
    } 

また、ここでは、この

[UIView transitionWithView:view2 duration:0.5 
     options:UIViewAnimationTransitionFlipFromLeft //change to whatever animation you like 
     animations:^ { [window addSubview:view2]; } 
     completion:nil]; 
0
 Can you post some code regarding this .Because if you click on Segment change 
it will change the Views.IF you take two views on same interface Builder. 
     Try out this 

    IBOutlet UIView *viewA; 
    IBOutlet UIView *viewB; 

    in .m file 



-(IBAction)SegmentChange 
{ 
    if(segment.selectedSegmentIndex==0) 
    { 
     viewA.hidden=NO; 
     viewB.hidden=YES; 


    } 

    else if(segment.selectedSegmentIndex==1) 
    { 
     [self.View addSubview:viewB]; 
     viewA.hidden=YES; 
     viewB.hidden=NO; 

    } 

} 
関連する問題