In a given event handler (not the "shouldAutorotateToInterfaceOrientation" method) how do I detect the current iPad orientation? I have a text field I have to animate up (when keyboard appears) in the Landscape view, but not in the portrait view and want to know which orientation I'm in to see if the animation is necessary.
相关问题
- how do you prevent page scroll in textarea on mobi
- How to change the backgroundColor for all UITableV
- The bundle identifier cannot be changed from the c
- execute method when iPhone enters landscape mode
- iPad Landscape messing up touches began
相关文章
- How do you detect key up / key down events from a
- Loss of variables switching orientations
- Can I release an app without the device?
- Flutter Camera Preview not rotating with phone ori
- Universal iPad App rejected because of launch cras
- What does the “Use for Development” button in Xcod
- Does the iOS-Simulator use multiple cores?
- iPad modal form sheet takes up the whole screen an
I think
is not really reliable. Sometimes it works, sometimes not... In my apps, I use
and it works great!
In your view controller, get the read-only value of self.interfaceOrientation (the current orientation of the interface).
I found a trick to solve the FaceUp orientation issue!!!
Delay the orientation check till AFTER the app has started running, then set variables, view sizes, etc.!!!
You can addSubviews, position elements, etc. in the 'setStuff' function ... anything that would initially depend on the orientation!!!
:D
-Chris Allinson
You can achieve this by two ways:
1- By using the following method:
**Put the following line in the
-(void)viewDidLoad
Method:then put this method inside your class
The above method will check the orientation when the device will be rotated
2- The second way is by inserting the following notification inside
-(void)viewDidLoad
then put the following method inside your class
The above method will check the orientation of the status bar of the ipad or iPhone and according to it you make do your animation in the required orientation.
I don't know why, but every time my app starts, the first 4 are right, but subsequently I get the opposite orientation. I use a static variable to count this, then have a BOOL to flip how I manually send this to subviews.
So while I'm not adding a new stand-alone answer, I'm saying use the above and keep this in mind. Note: I'm receiving the status bar orientation, as it's the only thing that gets called when the app starts and is "right enough" to help me move stuff.
The main problem with using this is the views being lazily loaded. Be sure to call the view property of your contained and subviews "Before" you set their positions in response to their orientation. Thank Apple for not crashing when we set variables that don't exist, forcing us to remember they break OO and force us to do it, too... gah, such an elegant system yet so broken! Seriously, I love Native, but it's just not good, encourages poor OO design. Not our fault, just reminding that your resize function might be working, but Apple's Way requires you load the view by use, not by creating and initializing it