142011
 

今天下午发现,在UITabBar的子显示对象的- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 有点问题,屏幕旋转了,只是调用了UITabBar的shouldAutorotateToInterfaceOrientation,容器内部的显示对象并不会做出反应。那么只能检测屏幕的旋转事件了再做出相应的动作了

 



// Do any additional setup after loading the view from its nib.

//----- SETUP DEVICE ORIENTATION CHANGE NOTIFICATION -----

UIDevice *device = [UIDevice currentDevice]; //Get the device object

[device beginGeneratingDeviceOrientationNotifications]; //Tell it to start monitoring the accelerometer for orientation

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; //Get the notification centre for the app

[nc addObserver:self //Add yourself as an observer

selector:@selector(orientationChanged:)

name:UIDeviceOrientationDidChangeNotification

object:device];

 

 

 



- (void)orientationChanged:(NSNotification *)note

{

UIView *ftView = [self.view viewWithTag:200];

if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)

{

[ftView setFrame:CGRectMake(0, 0, 480, 200)];

}else

{

[ftView setFrame:CGRectMake(0, 0, 320, 360)];

}

}

 ref:http://www.ios-developer.net/iphone-ipad-programmer/development/notifications/orientation-change-notification
 Posted by at 6:01 下午  Tagged with:

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>