现在的位置: 首页 > 综合 > 正文

常用到的一些判断是否为iphond 或ipad的方法

2014年02月27日 ⁄ 综合 ⁄ 共 832字 ⁄ 字号 评论关闭

判断是否为设备是否为ipad

#define IS_IPAD() ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] && \

[[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

#define INTERFACE_IS_PAD     ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) 

#define INTERFACE_IS_PHONE   ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 

判断屏幕摆放方式

 if (UIInterfaceOrientationIsLandscape(orientation)) {

        width = bounds.size.height;

        height = bounds.size.width;

    }

其中orientation可以通过

self.interfaceOrientation 获得

转屏会触发的方法

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

{

    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

    //转屏时使页面视图的位置改变

    [self centerButtonForInterfaceOrientation:toInterfaceOrientation];

}

抱歉!评论已关闭.