약간의 문제가 있습니다. UINavigationController 막대를 사용하여 응용 프로그램을 개발하려하지만 tableView가 회전해도 회전하지 않습니다. 내 응용 프로그램이 지금 무엇인지 알 수 있도록 조금 소개해 드리겠습니다 : IB에서 생성되고 AppController.h와 appDelegate.h에서 생성 된 UINavigationController에 링크 된 UITableView가 있습니다. tableView의 모든 항목을 클릭 할 수 있으며 다른 viewController로 이동하지만이 부분은 현재 중요하지 않습니다. 난 지금 메인보기에서 순환 게재를 지원하려고합니다.UINavigationBar가 회전하지 않습니다.
내가 이렇게 내 AppDelegate.h에 UINavigationController가를 만듭니다
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UINavigationController *navigation;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIViewController *viewController;
그리고 AppDelegate.m에서 나는이 작업을 수행 : 내 ViewController.m있는 viewDidLoad 방법에 노력했다
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
return YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
ViewController *viewController = [[ViewController alloc] init];
viewController.title = @"Agrinuvo";
[navigation pushViewController:viewController animated:NO];
navigation = [[UINavigationController alloc] initWithRootViewController:viewController];
navigation.navigationBar.tintColor = [UIColor darkGrayColor];
[[UIBarButtonItem appearance] setTintColor:[UIColor orangeColor]];
[_window addSubview:navigation.view];
}
이들 :
self.navigationController.navigationBar.autoresizesSubviews = YES;
self.navigationController.navigationBar.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
UINavigationBar의 크기를 조정할 수 있지만 회전 할 수 없습니다. (여전히 ViewController.m에서) 내 인생 :
-(void) orientationChanged
{
CGRect frame = self.navigationController.navigationBar.frame;
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait)
{
self.view.transform = CGAffineTransformMakeRotation(0);
frame.size.height = 44;
frame.origin.y = 15;
}
if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)
{
self.view.transform = CGAffineTransformMakeRotation(M_PI * 1);
frame.size.height = 44;
}
if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)
{
self.view.transform = CGAffineTransformMakeRotation(M_PI * -0.5);
frame.size.height = 32;
}
if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft)
{
self.view.transform = CGAffineTransformMakeRotation(M_PI * 0.5);
frame.size.height = 32;
}
self.navigationController.navigationBar.frame = frame;
}
아, 그래, 나 또한 내 모든 컨트롤러에서이 방법을 시도하고 그들 모두에 YES를 반환하지만, 내비게이션 바는 여전히 회전하지 않습니다.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
그래서 NavigationBar를 실제로 회전시킬 수 있는지 궁금합니다. 또한 만들어야 할 것처럼 그것을 만들 수 있습니까? 이 방법으로 UINavigationController를 시작해야합니까? 아니면 IB로 만들고 UHavigation 클래스를 .h 클래스에 연결해야합니까?
긴 읽기죄송하고 당신이
내비게이션 컨트롤러를 창에 대한 루트보기 컨트롤러로 사용하지 않는 이유는 무엇입니까? 그렇게하면 문제가 해결 될 수도 있습니다. – rdelmar
와우. 그건 실제로 ... - .- 이제 테이블 뷰가 제대로 회전하지 않는 문제가 1 개 남았습니다. 답변을 수락 할 수 있도록 귀하의 의견에서 답을 만들어 주시겠습니까? 아니면 그냥 질문을 삭제해야합니까? –