设置标签 ‘animation’

如何让某个ViewController支持屏幕旋转 来自Mars

看到这篇不错, 直接转载过来了, 没什么可解释的,一看就明白 :)

出处: http://www.marsiphone.cn/tag/uidevice/

整个程序需要支持横竖屏切换得时候,会比较简单,在每个ViewController 的

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

方法中,return YES; 就好。

可如果只是要某个VC( = View Controller)支持横竖屏切换呢?单独在那个view controller中像上面那样做是没有效果的。

这个时候我们可以取 UIDevice的 Orientation来判定:

1、在VC中注册 UIDevice 的 UIDeviceOrientationDidChangeNotification 通知:

NSNotificationCenter *center = [NSNotificationCenter defaultCenter];

[center addObserver:self selector:@selector(doRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];

2、在自己的 doRotate函数里面处理:

- (void)doRotate:(NSNotification *)notification{

UIDevice *myDevice = [UIDevice currentDevice];

UIDeviceOrientation deviceOrientation = [myDevice orientation];

UIApplication *app = [UIApplication sharedApplication];

[app setStatusBarOrientation:deviceOrientation];

}

3.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

也是要 return YES;

Different between viewDidDisappear & viewWillDisappear

Recently I have a proj using UIView animation, the animation delegated to a view’s delegate. View’s delegate is a view controller in list of nav Controllers.
Clear, then when I pop out the controller , all of the views and the controller should be released, BUT the animation CAN NOT stop, so a bad_access throwd out when animation finish, bcz the delegate had been released then.
After some digging, viewDidDisappear & viewWillDisappear come to the ground, viewDidDisappear would be right! drop lines if you have clearly knowladged.

回到顶部

关于我:

  • iPhone 开发者. 自由职业者.
  • 苹果忠实用户. 完美主义者.
  • Email/iChat/MSN/GTalk: i@imi.im
  • Twitter/Sina: @TraWor
  •  

    Switch to our mobile site