2012-10-04 119 views
0

我需要用iPhone旋轉一點幫助在橫向模式下的導航欄不被拉伸iPhone旋轉景觀

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // Override point for customization after application launch. 

    UIImage *navBarImage = [UIImage imageNamed:@"nav-bar.png"]; 
    [[UINavigationBar appearance] setBackgroundImage:navBarImage 
             forBarMetrics:UIBarMetricsDefault]; 

    UIImage *barButton = [[UIImage imageNamed:@"bar-button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)]; 
    [[UIBarButtonItem appearance] setBackgroundImage:barButton forState:UIControlStateNormal 
              barMetrics:UIBarMetricsDefault]; 

    UIImage *backButton = [[UIImage imageNamed:@"back-button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0,15,0,6)]; 
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButton forState:UIControlStateNormal 
                barMetrics:UIBarMetricsDefault]; 

    return YES; 
} 

回答

0

您不要在此method.First所有你必須返回寫這個代碼是在方法 -

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
return YES; 
} 

然後你必須使用:

-(void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)orientation 
{ if(orientation == UIInterfaceOrientationPortrait) 
// here your code 
}