手機屏幕旋轉時,試圖控制器可以相應一些方法,可以再這些方法里自己布局視圖

旋轉方向的枚舉類型
typedefNS_ENUM(NSInteger, UIInterfaceOrientation) {
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
};
是否支持旋轉
- (BOOL)shouldAutorotate
{
NSLog(@"%s",__FUNCTION__);
returnNO;
}
在旋轉某一個方向時,是否支持旋轉
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
NSLog(@"%s",__FUNCTION__);
returnNO;
}
將要旋轉時走的方法,可以判斷要轉向的方向
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
NSLog(@"%s %f",__FUNCTION__,duration);
}
視圖將要布局子視圖
window調整顯示的view controller的bounds,由于view controller的bounds發生變化,將會觸發 viewWillLayoutSubviews 方法。
- (void)viewWillLayoutSubviews
{
NSLog(@"%s",__FUNCTION__);
}
視圖完成布局子視圖
- (void)viewDidLayoutSubviews
{
NSLog(@"%s",__FUNCTION__);
}
接著當前view controller的 willAnimateRotationToInterfaceOrientation:duration: 方法將會被調用。系統將會把該方法中執行的所有屬性變化放到動animation block中。
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
NSLog(@"%s %f",__FUNCTION__,duration);
}
旋轉完成執行的方法
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
NSLog(@"%s",__FUNCTION__);
}
另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
網頁名稱:ios屏幕旋轉-創新互聯
本文地址:http://www.yijiale78.com/article34/disdse.html
成都網站建設公司_創新互聯,為您提供網站設計、移動網站建設、建站公司、網站排名、靜態網站、網頁設計公司
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯