about iPhone app,UIViewController Class provides the basic view management pattern . When the device changes direction view controller The view of will automatically rotate with it . If the view and subview autoresizing Property settings are right , At this time, the view does not rotate with the device , Maybe the following reasons :
1.view controller The proxy method is not complete
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
It's going to come true shouldAutorotateToInterfaceOrientation Method , meanwhile shouldAutorotateToInterfaceOrientation Method to return YES To support all directions of rotation
2.view controller Of UIView Property embedded in UIWindow in , It's not an additional view controller
You might notice shouldAutorotateToInterfaceOrientation The method will only be in view controller It's called at startup , Will not be called because of the set rotation . This is because view controller The view that binds them to manage ,view controller It's part of the response chain used to process time .view controller It's from UIResponder inherited , At the same time, he is inserted into the view he manages and his superview Between . therefore , The usual practice is in your app There's a lord in it view controller As part of the response chain . Usually, a main view controller, for example UINavigationController, UITabBarController perhaps UIViewController To UIWindow On .
for example
[myWindow addSubview:primaryViewController.view];
If you add another view controller Of UIView Attributes to UIWindow(anotherController And the Lord view controller On the same level )
[myWindow addSubview:anotherController.view];
anotherController Rotation events will not be accepted , Only the first one view controller(primaryViewController) Will accept rotation Events .
3. You added view controller Of UIView Attributes to UIWindow As subview, But too early release it .
UIWindow Meeting retain View , instead of view controller. You can't be premature release He . stay UIApplicationDelegate He is defined in subclass as retain attribute .
4. stay UITabBarController perhaps UINavigationController The son of view controller No support for the same direction .
To make sure that all the children view controller The rotation is correct , Every one of you view controller, every last tab Or, uh navigation It's all done shouldAutorotateToInterfaceOrientation, And it has to support rotation in the same direction , That is to say, for positions in the same direction, return to YES.
5. rewrite -(id)init: perhaps -(id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle Method is not called super.
For object initialization , In your view controller Of init perhaps initWithNibName Method must call super.
Audio and video play :http:blog.sina.com.cn/s/blog_6f1a34260100tlvx.html
iphone Provides excellent gravity accelerometers , Can be very sensitive to the phone's screen state . In our development iphone When applied , To improve the user experience , Will monitor the current state of the screen . about UIViewController Come on , There are several ways . The simplest is that we can use Interface Builder This tool helps us to realize simple screen interface adaptation , Only need IB Medium Size Insepector Through the right Autosizing Of Set to achieve . But it's only a simple interface , If the interface is complex , Maybe we need to implement it through code . Second, we can get through to willAnimateRotationToInterfaceOrientation:duration: An override of this method to configure our auto rotation . Third , You can also get through to willAnimateFirstHalfOfRotationToInterfaceOrientation:duration: And willAnimateSencondHalfOfRotationToInterfaceOrientation:duration: Rewriting of two methods to more finely configure our auto rotate view . Special attention What is important is that when the previous method is executed , At this time UIInterfaceOrientation It's still the original value before the rotation , Only when the latter method is executed UIInterfaceOrientation It's the value of the screen rotation .
UIViewController There are no more articles on the reasons for rotating with the device
- Unity The project is on Amazon KindleFire Solution for incorrect rotation on device
Premise : On Amazon devices , The version required by the headquarters must be used LandscapeLeft Direction . According to experience , stay UnityPlayerSettings Set in Orientation that will do . Problem performance : ...
- Upload photos on the mobile end preview +Draw on Canvas's Demo( solve iOS Wait for the device photo to rotate 90 Degree bug)
background : One of my mobile terminals H5 project , Requirements are as follows : Need one : Select or take photos and preview them on the page Demand two : And then draw on canvas On the canvas here , Let's see one first demo(http://jsfiddle.net/q ...
- UIWindow And UIView
UIView And UIWindow * Generally, there is only one application UIWindow object . All the controls are in UIWindow It's shown on the Internet . Every UIView Objects all have one window attribute , At present view On which form . ...
- XCODE shouldAutorotateToInterfaceOrientation For different versions When the device rotates in different directions The realization of the corresponding rotation direction of the view
For devices with different version numbers , When rotating, the view should be rotated accordingly , So different versions , How the code is implemented , How to limit the direction of rotation ? Here is Xiaobian's personal opinion ! // The version number is 3.5 -5.0 -(BOOL)shouldAutor ...
- ##DAY3 Custom view 、 View controller 、 The view controller specifies the view 、loadView、 viewDidLoad、MVC、 Screen rotation 、 Memory warning
##DAY3 Custom view . View controller . The view controller specifies the view .loadView. viewDidLoad.MVC. Screen rotation . Memory warning #pragma mark ——————— To customize a view —————— ...
- UIViewController/ApplicationSequ…
UIViewController ApplicationSequence UI-03 Be careful : NSLog(@"%s %d",__FUNCTION__,__LINE__); // ...
- iOS Screen rotation in shouldAutorotate and supportedInterfaceOrientations The order of
this 2 individual UIViewController Properties of , It's all about rotation , When the device rotates , First we'll look at the root controller Of shouldAutorotate Is rotation allowed , If allowed , Re pass supportedIn ...
- ios View Switch between Screen rotation
6.3 View Switch between In the above exercise, we deal with the horizontal and vertical interface layout by moving and resizing the components . But when there are many components in the interface , It's a real hassle to do this for every component . So let's see ...
- iOS Set up the vertical screen , Play video can be arbitrary rotation solution , Close test available
I found a lot of ways on the Internet before , It's all compulsory horizontal screen , But if the device is turned off, the rotary lock , Force the device to stand up behind the horizontal screen , The player will also follow , But I can't go back . Now the project calls for app The default is vertical screen , It can only rotate freely when playing in full screen , therefore ...
Random recommendation
- from I/O Let's talk about epoll Why efficient
In the last article , Some basic concepts of network programming are discussed . In practical use , The most used is I/O Reuse the , does select,poll,epoll Many people talk about the Internet and say epoll, Think epoll Efficiency is the highest . Simply think so ...
- errorlevel
------siwuxie095 errorlevel Program return code usage :echo %errorlevel% Check the return code of the current program ( That is, the return value ), To know if the program or command line was executed successfully . DOS There is a return after the execution ...
- Creating Timer in Oracle D2k / Forms 6i and Displaying a Clock
Creating Timer in Oracle D2k / Forms 6i and Displaying a Clock This is about timer in D2k An externa ...
- UIView Life cycle summary of
preface : loadView.viewDidLoad.viewDidAppear.initWithNibName.awakeFromNib And so on often appear in UIViewController Introduction to methods in . These parties ...
- DataRow.RowState attribute
RowState The value of depends on two factors : The type of operation that has been performed on the row , And whether it has been done to DataRow Called AcceptChanges. private void DemonstrateRowState() ...
- Solr4.8.0 Source code analysis (18) The cache mechanism of ( One )
Solr4.8.0 Source code analysis (18) The cache mechanism of ( One ) I've been introducing commit When I was young, I introduced getSearcher() The implementation of the , And mentioned Solr Preheating warn. So this article will start to learn in detail Solr Cache mechanism ...
- Three minutes to teach you Git( sixteen ) - Statistics
Sometimes I want to count the situation of the warehouse , For example, the amount of code . Contributors and things like that . 1 Count someone's commit Number git log --author="$(git config --get user.name)" ...
- You know how to do it for iOS Did the project change its name ?
We are iOS In development , It's hard to avoid the situation that half of the project needs to change its name . If the project name is too bad , Project names always look uncomfortable , Conscientious developers may want to change the name of the project , So you can use the content recorded in this article . If we develop two ...
- Hand to hand teaching you to write vue Plug in and release ( Two )
Preface : Last one https://www.cnblogs.com/adouwt/p/9211003.html, Speaking of a complete vue Plug-in development . Release process , To sum up, this is one thing , How to inject vue, If ...
- Shell From introduction to mastery, the third step : Expressions and operators
3.1 Conditional expression expression Example [ expression ] [ 1 -eq 1 ] ` expression ` ` 1 -eq 1 ` test expression test 1 -eq 1 ...