Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Programmer

macrumors member
Original poster
Jun 16, 2009
79
0
I am creating a game where you tap a character when he appears. I have UIImageViews set up with buttons over them is there a way to say that only if the image is being displayed that the button will be pushed?
 
I am creating a game where you tap a character when he appears. I have UIImageViews set up with buttons over them is there a way to say that only if the image is being displayed that the button will be pushed?

Set a BOOL value so BOOL imageAppeared = NO;
then when the image has appeared set imageAppeared = YES;

then in the IBAtion for the button have at the start
if (imageAppeared) { // so if the imageAppeared is YES Then:
//code to do what ever you want here
}
 
But...

what would the BOOL be like with the Auto Rotation of the interface

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 
what would the BOOL be like with the Auto Rotation of the interface

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

Not sure quite what you mean,
That method return's yes if it should auto rotate to the orientation specificed (default code will say only vertical), but if you specify orientationLeft then when you rotate it left, it will return yes and rotate it, if you haven't specificed it then when you rotate the phone it will call that method and return no and not change the view in any way

if you want to check which way the phone is position example the home button is at the bottom, on the left, right or up top
then maybe create an NSIntger, and give it a number depending on the direction it is being held, 0 is vertical, 1 is left, 2 is right etc
then just check what that number is when you need to do something if its held in a certain way

as i said not sure quite what you meant so said what the method does, and what i think you may have asked
 
I didn't mean that

Sorry for the mix up. I was using that as an example i was asking how do you set up the BOOL like do i say -(BOOL)ImageAppeared; in the .h and say
-(BOOL)ImageAppeared = NO in the .m and so on so forth?
 
Sorry for the mix up. I was using that as an example i was asking how do you set up the BOOL like do i say -(BOOL)ImageAppeared; in the .h and say
-(BOOL)ImageAppeared = NO in the .m and so on so forth?

in the .h do
BOOL imageAppeared;

then in the .m viewdidLoad or where ever you initalise everything:
imageAppeared = NO;

then just change it like that throughout:
imageAppeared = YES
or to use it in an if statement: if (imageAppeared) or if(imageAppeared == YES)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.