- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
}
แต่พอเป็น iOS6 คำสั่งนี้ได้ถูกยกเลิกไป แล้วเพิ่ม 2 คำสั่งนี้เข้ามาแทน
- (NSUInteger)supportedInterfaceOrientations
{
}
- (BOOL)shouldAutorotate
{
}
ดังนั้นสิ่งที่ผมจัดการกับปัญหานี้คือสร้าง Category ของ UINavigationController ขึ้นมาแล้วใน ViewController เราก็เรียกใช้คำสั่งเหล่านี้ได้เลย เช่นผมมีคลาส ViewController อยู่หนึ่งตัวก็จะเรียกใช้แบบนี้ได้เลย ตัวแรกจะใช้งานสำหรับ iOS 5 ลงไป- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
ส่วน 2 ตัวนี้จะใช้สำหรับ iOS 6 ขึ้นไปครับ
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate
{
return YES;
}
สำหรับ Category นี้ผมเขียนไว้แล้วลอง ดาวโหลด ไปใช้งานกันได้เลยครับ :D
No comments:
Post a Comment