2012-04-12 3 views
1

appdelagte 클래스의 navigationcontroller에 이미지를 추가했습니다. 및iPad 앱에서 방향을 관리하는 방법

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    loginViewController = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:nil]; 

    [self.window addSubview:_navController.view]; 

    _navController.navigationBarHidden = NO; 
    navimage = [[UIImageView alloc] init]; 
    navimage.frame = CGRectMake(300, 18, 177, 47); 

    navimage.image = [UIImage imageNamed: @"logo.png"]; 

    [_navController.view addSubview:navimage]; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ 
return YES; 
} 

그러나 탐색 이미지 위치에 네 설정은 변경되지 않습니다. 프레임은 두 모드에서 동일하게 유지됩니다.

내비게이션 컨트롤러 이미지의 경우 해결 방법을 알려주세요.

답변

1

당신은 당신의 컨트롤러에서 컨트롤러의 viewDidLoad 방법 및 shouldAutorotateToInterfaceOrientation이 추가해야합니다.

-(void)viewDidLoad{ 
navimage = [[UIImageView alloc] init]; 
navimage.frame = CGRectMake(300, 18, 177, 47); 

navimage.image = [UIImage imageNamed: @"logo.png"]; 

[_navController.view addSubview:navimage]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ 
return UIInterfaceOrientationIsPortrait(toInterfaceOrientation); 
} 
1
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ 
    return YES; 
} 

위 (귀하의 경우 LoginViewController)을 UIViewController 클래스에서 작성해야 코드가 아닌 AppDelegate인치 당신은 세로 방향을 필요로하는 경우

그리고, 이것을 사용 :

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ 
    return UIInterfaceOrientationIsPortrait(toInterfaceOrientation); 
} 
관련 문제