Note that there are some explanatory texts on larger screens.

plurals
  1. POImage Changer in iOS
    primarykey
    data
    text
    <p>I'm trying to get my app to do a basic background change from 3 screens. Here is my .h file.</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @class BIDYellowViewController; @class BIDBlueViewController; @class BIDGreenViewController; @interface BIDSwitchViewController : UIViewController @property (strong, nonatomic) BIDYellowViewController *yellowViewController; @property (strong, nonatomic) BIDBlueViewController *blueViewController; @property (strong, nonatomic) BIDGreenViewController *greenViewController; - (IBAction)switchViews:(id)sender; @end </code></pre> <p>and here is my method in the .m file that when the IBAction button is pressed, the superview will go from one screen to the next and continue in the loop of rotating them.</p> <pre><code>- (IBAction)switchViews:(id)sender { //animations [UIView beginAnimations:@"View Flip" context:nil]; [UIView setAnimationDuration:1.25]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; //loads yellow if (self.yellowViewController.view.superview == nil) { if (self.yellowViewController == nil) { self.yellowViewController = [[BIDYellowViewController alloc]initWithNibName:@"YellowView" bundle:nil]; } [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES]; //removes blue [self.blueViewController.view removeFromSuperview]; [self.view insertSubview:self.yellowViewController.view atIndex:0]; //loads green } else if(self.greenViewController.view.superview == nil){ if (self.greenViewController == nil) { self.greenViewController = [[BIDGreenViewController alloc] initWithNibName:@"GreenView" bundle:nil]; } [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES]; //removes yellow [self.yellowViewController.view removeFromSuperview]; [self.view insertSubview:self.greenViewController.view atIndex:0]; //loads blue } else if(self.blueViewController.view.superview == nil){ if (self.blueViewController == nil) { self.blueViewController = [[BIDBlueViewController alloc] initWithNibName:@"BlueView" bundle:nil]; } [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES]; //removes green [self.greenViewController.view removeFromSuperview]; [self.view insertSubview:self.blueViewController.view atIndex:0]; } [UIView commitAnimations]; } </code></pre> <p>the problem I'm having is that on the first loop, it repeats green screen twice and then continues on and works properly. Am I missing something or should I be using a switch: case statement( and if so how would I do that)?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload