2014-09-13 3 views

답변

1

두 가지 방법으로 해결할 수 있습니다. 프레임 사용을 주장하는 경우보기를 그리기 전에 프레임 크기를 확인해야합니다. 장치를 확인합니다 그것이 당신의 유틸 파일에 방법을 쓰고에 대해 당신이 갈 수있는 한 가지 방법이 같은 : 우리가 우리가 사용하고있는 장치 일단, 우리는 그에 따라 프레임을 설정할 수 있습니다

+ (NSString *)getHardwareModel { 
    AppDelegate_iPhone *appDelegate_iPhone = (AppDelegate_iPhone *) [[UIApplication sharedApplication] delegate]; 
    size_t size; 
    // get the size of the returned device name 
    sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
    // allocate the space to store name 
    char *machine = (char*)malloc(size); 
    // get the device name 
    sysctlbyname("hw.machine", machine, &size, NULL, 0); 
    // place the name into a NSString 
    NSString *platform = [NSString stringWithCString:machine encoding: NSUTF8StringEncoding]; 
    free(machine); 

    appDelegate_iPhone.hardwareModel = platform; 

    return platform; 
} 

. 나는 iPhone6 ​​장치를 말할를 확인하고 싶어한다면, 나는 내 setFrameSize 방법으로 이런 짓을 할 것이다 :이 모든 것을 피할 것이다

NSString *hardwareVersion = [Utils getHardwareModel]; 
    NSString *[email protected]"x86_64"; 
    NSString *[email protected]"iPhone7,1"; 
    NSRange range =[hardwareVersion rangeOfString:target ]; 
    NSRange deviceRange =[hardwareVersion rangeOfString:deviceTarget ]; 
    NSLog(@"device=%@",hardwareVersion); 

    // Setting the frame size for the progress bar 


     if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { 
      if (range.location!=NSNotFound ||deviceRange.location!=NSNotFound) { 
       float frameSize = self.view.frame.size.width; 
       NSLog(@"Frame width===%f", frameSize); 
       self.view.frame = CGRectMake(0, 0, 480, 85); 
      } 

또 다른 방법은 자동 레이아웃을 사용하고 다른 화면을 기반으로 제약 조건을 설정하는 것입니다 크기. https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html

관련 문제