简体   繁体   English

如何找到iPhone的位置

[英]how to find position of iphone

I have 1 view ,now i click on it's subview 我有1个视图,现在我单击它的子视图

There are 2 conditions for that, 1> if subview is in portrait mode and then i switch it to landscape mode,at that time i wrote code and it works perfectly. 有2个条件,1>如果子视图处于纵向模式,然后将其切换为横向模式,那时候我编写了代码,它可以完美地工作。

[[UIDevice currentDevice]  beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(receivedRotate:) name: UIDeviceOrientationDidChangeNotification object: nil];


-(void) receivedRotate: (NSNotification*) notification
{

  self.View.autoresizingMask = UIViewAutoresizingFlexibleWidth/UIViewAutoresizingFlexibleHeight; 
}

but if i put my device initially in landscape mode and then click on subview then how to autoresizie subview 但是如果我最初将设备置于横向模式,然后单击子视图,然后如何自动调整子视图

My que:- How to find out the method for the position of device? 我的问题:-如何找出设备位置的方法? How to find my device is in portrait or landscape mode? 如何找到我的设备处于纵向或横向模式?

您可以检查[[UIDevice currentDevice]方向]。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM