Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Am i write in right code?

VoodooBabaVoodooBaba Posts: 12Registered Users
Hi, i am new in xcode. I learn it by myself so my knowledge is not much like you all. I hope you can share your knowledge and teach me to write with right one.

To the point, i'm writing code for flip animation between 2 view. This time my view can flip from main to other view and also can flip back to my main view. But the problem this time is, after flip to my main view, and i press again button, it can't flip to other view now, it flip only to my main view and so on and so on. please help.


#import \"FlipViewViewController.h\"

@interface FlipViewViewController ()

@end

@implementation FlipViewViewController
@synthesize yellowView;

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
[self setYellowView:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)gotoYellow:(id)sender {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[self view] cache:YES];
yellowView.frame = [self view].bounds;
[[self view] addSubview:yellowView];
[UIView commitAnimations];
}

- (IBAction)gotoWhite:(id)sender {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[self view] cache:YES];
[yellowView removeFromSuperview];
[UIView commitAnimations];
}
@end


this is my .h file


#import <UIKit/UIKit.h>

@interface FlipViewViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIView *yellowView;
- (IBAction)gotoYellow:(id)sender;
- (IBAction)gotoWhite:(id)sender;

@end


im using xcode 4.3.3, ios5, iphone, single view app.
Post edited by VoodooBaba on

Replies

  • Duncan CDuncan C Posts: 8,021Tutorial Authors, Registered Users
    VoodooBaba;438993 said:
    Hi, i am new in xcode. I learn it by myself so my knowledge is not much like you all. I hope you can share your knowledge and teach me to write with right one.

    To the point, i'm writing code for flip animation between 2 view. This time my view can flip from main to other view that is 'viewProcess' and also can flip back to my main view. But the problem this time is, after flip to my main view, and i press again readyBtn, it can't flip to other 'viewProcess' now, it flip only to my main view and so on and so on. please help.


    - (IBAction)readyBtn:(id)sender {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[self view] cache:YES];
    viewProcess.frame = [self view].bounds;
    [[self view] addSubview:viewProcess];
    [UIView commitAnimations];
    }

    - (IBAction)startBtn:(id)sender {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[self view] cache:YES];
    [viewProcess removeFromSuperview];
    [UIView commitAnimations];
    }


    this is my .h file

    - (IBAction)startBtn:(id)sender;
    - (IBAction)loopBtn:(id)sender;


    im using xcode 4.3.3, ios5, iphone

    What do you mean that you found a solution but can't find the right one? What works, and what doesn't?

    I would think you should be adding a new view and removing the old one in each of your button actions.
    Regards,

    Duncan C
    WareTo

    mug

    Animated GIF created with Face Dancer, available for free in the app store.
  • VoodooBabaVoodooBaba Posts: 12Registered Users
    sorry for my english. i attach file to here. it can flip from viewmain to YellowView also can flip back to viewmain but it can't flip again to yellowView. just flip at viewmain and so on. how to fix it?
    FlipView.zip
    1 x 1 - 48K
Sign In or Register to comment.