I am making one Paint application..The button marked with Red circle, I want it to be rotated 90 degree "when orientation is changed to Landscape mode".. Image marked with RED circle is placed on BUTTON.. So should i rotate button or image when orientation changes??
Hope this description will give you idea about my problem.. Thanks..
Please follow this link to see screenshot as i am not allowed to post image..
http://imageshack.us/photo/my-images/26/screenshot20110712at507.png/
You could do either but I think it would be easier to just flip the image 90 degrees. When your application switches to landscape have a new image, really just the old image turned 90 degrees, and set that as the image for the button. Hope this helps.
Well thats a sweet deal. Just copy paste the follwing code in your view controller (the one in which you want the buttons to be rotated).
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
else {
return NO;
}}
This might give you the idea of your target. Happy Coding..!
You can set the frame of UIButton in the following method as follows:
In.h class
IBOutlet UIButton *redButton;
And in.m class:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
redButton.frame = CGRectMake(100,50,100,50)
}
else
{
redButton.frame = CGRectMake(50,100,100,50)
}
return YES;
}
So, you can change the frame of your button as per the requirement.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.