我做它同时支持横向模式和肖像模式的一个项目,但现在我打有我project.I没有orentation设置如何在iPhone中设置设备方向?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
//return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
return YES;
}
,但没有用,当我按命令+右 - 箭头为向右旋转它旋转到左边,但视图和控制器没有改变到orentation.Then一些谷歌上搜索后,我得到这个代码
if (self.interfaceOrientation == UIInterfaceOrientationPortrait) {
// do stuff
}
但问题是我不知道如何写代码/ /做东西。请帮助我做到这一点。 在此先感谢。 编辑: 我把这个代码,它是工作,但whenthe模拟器再次变为纵向它不会是在默认mode.my代码
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight))
{
NSLog(@"Csantos shouldAutorotateToInterfaceOrientation: left or right");
//
table.transform = CGAffineTransformIdentity;
table.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
table.bounds = CGRectMake(0.0, 0.0, 320, 402);//[self.view setFrame:CGRectMake(0.0, 0.0, 768, 90)];
}
else
{
table.transform = CGAffineTransformIdentity;
table.transform = CGAffineTransformMakeRotation(degreesToRadian(360));
table.bounds = CGRectMake(0.0, 51, 320, 402);
}
return YES;
}*/
可能的重复:http://stackoverflow.com/questions/181780/is-there-a-documented-way-to-set-the-iphone-orientation – Dair