zoukankan      html  css  js  c++  java
  • 自定义Notification来实现rotate

    如果AViewContorller通过addSubview增加BViewController的view到界面中,当旋转iphone时,AViewController可以接到shouldAutorotateToInterfaceOrientation和- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration消息,但是在BViewController中是没有办法接到这个二
    个消息的(目前我发现是这样的),但是如果是通过navigationController然后通过- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated这个方式
    加入BViewController的话,是可以响应到二个方法的.
    但是在我的工程中我需要通过AddSubview来增加BViewController的View,但是也希望旋转时也能接受到device旋转的消息.

    目前我找到一种方法,共享给大家:

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotificati*****];     
     [[NSNotificationCenter defaultCenter] addObserver:self  
                                                 selector:@selector(didRotate:)  
                                                     name:@"UIDeviceOrientationDidChangeNotification"   
                                                   object:nil];
    - (void) didRotate:(NSNotification *)notification  
     {     
         UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];  
         if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)  
         {  
     
         }

     }

  • 相关阅读:
    azkaben任务调度器
    HQL练习
    Hive基本操作
    Spark cache、checkpoint机制笔记
    2021年元旦云南之旅
    2020年总
    Windows Server 2016 如何恢复.NET Framework 4.6
    numpy和tensorflow中的广播机制
    查看spark RDD 各分区内容
    Spark RDD的默认分区数:(spark 2.1.0)
  • 原文地址:https://www.cnblogs.com/easonoutlook/p/2642808.html
Copyright © 2011-2022 走看看