博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS开发——检测屏幕旋转
阅读量:4539 次
发布时间:2019-06-08

本文共 806 字,大约阅读时间需要 2 分钟。

步骤一、注册通知

1:  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];

 

步骤二、判断方向

 

1:  - (void)statusBarOrientationChange:(NSNotification *)notification
2:   
3:  {
4:   
5:  UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
6:   
7:  if (orientation == UIInterfaceOrientationLandscapeRight) // home键靠右
8:   
9:  {
10:   
11:  //
12:   
13:  }
14:   
15:  if (
16:   
17:  orientation ==UIInterfaceOrientationLandscapeLeft) // home键靠左
18:   
19:  {
20:   
21:  //
22:   
23:  }
24:   
25:  if (orientation == UIInterfaceOrientationPortrait)
26:   
27:  {
28:   
29:  //
30:   
31:  }
32:   

参考来源:

转载于:https://www.cnblogs.com/zeyang/p/4457913.html

你可能感兴趣的文章
PAT甲级——A1055 The World's Richest
查看>>
PAT甲级——A1036 Boys vs Girls
查看>>
PAT甲级——A1057 Stack
查看>>
PAT甲级——A1038 Recover the Smallest Number
查看>>
PAT甲级——A1058 A+B in Hogwarts
查看>>
PAT甲级——A1042 Shuffling Machine
查看>>
PAT甲级——A1063 Set Similarity
查看>>
PAT甲级——A1044 Shopping in Mars
查看>>
PAT甲级——A1065 A+B and C (64bit)
查看>>
PAT甲级——A1045 Favorite Color Stripe
查看>>
PAT甲级——A1066 Root of AVL Tree
查看>>
PAT甲级——A1047 Student List for Course
查看>>
PAT甲级——1072 Gas Station
查看>>
PAT甲级——A1053 Path of Equal Weight
查看>>
PAT甲级——A1073 Scientific Notation
查看>>
PAT甲级——A1054 The Dominant Color
查看>>
PAT甲级——A1075 PAT Judge
查看>>
PAT甲级——A1056 Mice and Rice
查看>>
PAT甲级——A1059 Prime Factors
查看>>
PAT甲级——A1080 Graduate Admission
查看>>