This is a rather basic question regarding the return value from a simple UIInterfaceOrientation object, I try this code:
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
BOOL orientacion = interfaceOrientation;
return orientacion;
}
and the conversion does it, so I thought a UIInterfaceOrientation object is equal to a boolean var?? is that a implicit typo or really UIInterfaceOrientation is equal to a boolean value..
UIInterfaceOrientationis anenum, which essentially means it’s an integer. Integers can be assigned to booleans. Many things can–booleans simply equate to true or false. If a boolean is set equal to0ornil, it is false. If it is set to anything other than0ornil(or some other#defined equivalent) it will be true. Since UIInterfaceOrientation is an enum (an integer), if it is equal to 0 the boolean will be false. If it is anything but 0 it will be true.The values of
UIInterfaceOrientation:The first on this list will equal
0. The next1, the next2, etc. SoUIDeviceOrientationUnknownwill set the boolean to false; anything else will set it to true.In any case, you’re not using this function correctly. The code inside this function needs to read:
Set
someOrientationYouWantToWorketc to values from the enums I posted above. Whichever orientations you want to work, returnYESfor. Else it will returnNO.