what method will called when we start to rotate device and after it finished

后端 未结 5 754
抹茶落季
抹茶落季 2021-02-01 16:54

i want to detect a rotation process on ipad programmatically. In this case i want to set a boolean into yes, when the rotation will begin, and set it false after the rotation di

5条回答
  •  北荒
    北荒 (楼主)
    2021-02-01 17:24

    For newcomers to this post, the methods suggested by Nekto have become deprecated in iOS 8. Apple suggests to use:

    -(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator
    

    You can use the "size" parameter as an easy way to get whether it is transitioning to portrait or landscape.

    i.e.

    if (size.width > size.height)
    {
        // Position elements for Landscape
    }
    else
    {
        // Position elements for Portrait
    }
    

    More info is availablein the Docs.

提交回复
热议问题