Best way to programmatically detect iPad/iPhone hardware

前端 未结 10 909
借酒劲吻你
借酒劲吻你 2020-11-27 14:14

The reason I need to find out is that on an iPad, a UIPickerView has the same height in landscape orientation as it does in portrait. On an iPhone it is different. The iPad

10条回答
  •  攒了一身酷
    2020-11-27 14:39

    Put this method in your App Delegate so that you can call it anywhere using [[[UIApplication sharedApplication] delegate] isPad]

    -(BOOL)isPad
    {
        BOOL isPad;
        NSRange range = [[[UIDevice currentDevice] model] rangeOfString:@"iPad"];
        if(range.location==NSNotFound)
        {
            isPad=NO;
    
    
        }
        else {
            isPad=YES;
        }
    
        return isPad;
    }
    

提交回复
热议问题