shouldAutorotateToInterfaceOrientation方法没有在ipad中调用

时间:2014-02-20 05:10:00

标签: ios ipad

我正试图在设备漫游时获取设备的方向。我的代码适用于iphone,但 ipad shouldAutorotateToInterfaceOrientation 方法未调用。我已经将标签视图控制器作为根视图控制器,并且我已经在第一个标签的视图控制器上编写了代码。

源代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation  
{  
    //[self configureForOrientation:interfaceOrientation];
    return YES;  
}  

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration  
{  
    [self configureForOrientation:toInterfaceOrientation];  
}  

-(void)configureForOrientation:(UIInterfaceOrientation)interfaceOrientation    
{    
if (UIInterfaceOrientationIsLandscape(interfaceOrientation))  
{  
    NSLog(@"Land");  
    if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)  
    {   
        NSLog(@"Land ipad");  
        view_home.frame = CGRectMake(0,0,1004,768);  
        scroll_home.frame = CGRectMake(0,0,1004,768);  
        scroll_home.contentSize = CGSizeMake(scroll_home.frame.size.width,scroll_home.frame.size.height);  
        scroll_home.scrollEnabled = true;  
        btntitle.frame =  CGRectMake(0,0,1004,52);  
    }  
    else  
    {

        view_home.frame = CGRectMake(0,0,568,320);
        status.frame = CGRectMake(0, 0, view_home.bounds.size.width, 20.0f);
        scroll_home.frame = CGRectMake(0, 0, 568,430);
        scroll_home.contentSize = CGSizeMake(scroll_home.frame.size.width,scroll_home.frame.size.height);
        scroll_home.scrollEnabled = true;
        btntitle.frame =  CGRectMake(0,0,480,48);
    }
}
else
{
    NSLog(@"Port");
    if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
    {
        view_home.frame = CGRectMake(0,0,768,1004);
        scroll_home.frame = CGRectMake(0,0,768,1004);
        //scroll_home.contentSize = CGSizeMake(scroll_home.frame.size.width,scroll_home.frame.size.height);
        scroll_home.scrollEnabled = false;
        btntitle.frame =  CGRectMake(0,0,768,52);

    }
    else
    {
        view_home.frame = CGRectMake(0,0,320,548); //548
        scroll_home.frame = CGRectMake(0, 0, 480, 568);
        //scroll_home.contentSize = CGSizeMake(scroll_home.frame.size.width,scroll_home.frame.size.height);
        scroll_home.scrollEnabled = false;
        btntitle.frame =  CGRectMake(0,0,320,48);
    }
}
}

0 个答案:

没有答案