ipad – 使用insertSubview时的方向问题

ipad – 使用insertSubview时的方向问题,第1张

概述在使用以下代码在分割视图顶部显示视图时,我遇到了方向问题. [window addSubview:aSplitViewController.view];[window insertSubview:aViewController.view aboveSubview:aSplitViewController.view]; 普通视图有几个按钮和标签. 所以我面临的问题是第一个视图以横向模式打开,但视图 在使用以下代码在分割视图顶部显示视图时,我遇到了方向问题.

[window addSubvIEw:aSplitVIEwController.vIEw];[window insertSubvIEw:aVIEwController.vIEw aboveSubvIEw:aSplitVIEwController.vIEw];

普通视图有几个按钮和标签.

所以我面临的问题是第一个视图以横向模式打开,但视图上的标签和按钮处于纵向模式.

更新:这是一些代码,所以如果有人想看到更多的细节……

在我的App代表中

- (voID) makeSplitVIEwController {NSMutableArray *controllers = [NSMutableArray arrayWithArray:tabbarController.vIEwControllers];// First tabbbar item// detail vIEwdetailVIEwController = [[DetailVIEwController alloc] initWithNibname:@"DetailVIEw" bundle:nil];UINavigationController *navDetailVIEw = [[[UINavigationController alloc] initWithRootVIEwController:detailVIEwController] autorelease];navDetailVIEw.hIDesBottombarWhenPushed = YES;// root vIEwrootVIEwController = [[RootVIEwController alloc] initWithStyle:UItableVIEwStylePlain];rootVIEwController.detailVIEwController = detailVIEwController;rootVIEwController.navigationItem.Title = @"List";UINavigationController *navRootVIEw = [[[UINavigationController alloc] initWithRootVIEwController:rootVIEwController] autorelease];navRootVIEw.hIDesBottombarWhenPushed = YES;navRootVIEw.navigationbar.barStyle = UIbarStyleBlackTranslucent;splitVIEwController = [[UISplitVIEwController alloc] init];splitVIEwController.tabbarItem.Title = @"Face Sheet";splitVIEwController.tabbarItem.image = [UIImage imagenamed:@"gear1.png"];splitVIEwController.navigationItem.Title = @"Face Sheet";splitVIEwController.vIEwControllers = [NSArray arrayWithObjects:navRootVIEw,navDetailVIEw,nil];splitVIEwController.delegate = detailVIEwController;splitVIEwController.hIDesBottombarWhenPushed = YES;[controllers addobject:splitVIEwController];// Second tabbbar itemscoreVIEwController = [[scoreCardVIEwController alloc] initWithNibname:@"tableVIEwController" bundle:nil];scoreVIEwController.tabbarItem.Title = @"score Card";scoreVIEwController.tabbarItem.image = [UIImage imagenamed:@"gear1.png"];scoreVIEwController.navigationItem.Title = @"score Card";[controllers addobject:scoreVIEwController];tabbarController.vIEwControllers = controllers;

}

- (BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    // OverrIDe point for customization after application launch.// Create tabbartabbarController = [[UITabbarController alloc] init];//tabbarController.delegate = self;// Set window[window addSubvIEw:splashController.vIEw];[window insertSubvIEw:tabbarController.vIEw belowSubvIEw:splashController.vIEw];[self.window makeKeyAndVisible];application.statusbarOrIEntation = UIInterfaceOrIEntationLandscapeRight;return YES;

}

这是我的SplashScreenVIEw中的代码

- (IBAction) proceedbuttonClick:(ID)sender {// Initialize loginpopvIEwPhysicianLoginVIEwController *loginVIEwController = [[PhysicianLoginVIEwController alloc] init];popOverController = [[UIPopoverController alloc] initWithContentVIEwController:loginVIEwController];popOverController.popoverContentSize = CGSizeMake(350,200);popOverController.delegate = self;// Set a notification to dismiss it later[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(loginVIEwControllerDone:) name:@"loginVIEwControllerDone"  object:popOverController.contentVIEwController];// Present popoverif ([popOverController isPopoverVisible]){    [popOverController dismisspopoverAnimated:YES];}else {    [popOverController presentPopoverFromrect:CGRectMake(485,600,100,100) inVIEw:self.vIEw permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];}

}

// dismiss popvIEw controller and setup the tabbar- (voID)loginVIEwControllerDone:(NSNotification *)notification{  [[NSNotificationCenter defaultCenter] removeObserver:self];// button in content vIEw controller was tapped,dismiss popover...[self.popOverController dismisspopoverAnimated:YES];// remove subvIEw[self.vIEw removeFromSupervIEw];// set tabbari3EAppDelegate *appDelegate = (i3EAppDelegate *) [[UIApplication sharedApplication]delegate];[appDelegate makeSplitVIEwController];

}

如果有人能够指出我哪里出错了会很棒.我已经坚持了这个问题好几天了,我已经尝试了一切让我想到的东西……

解决方法 UIWindow有一个子视图,用于旋转并将其他视图放在其中.您需要将自己插入根视图(或更低的位置),而不是窗口.看看 – [UIWindow rootVIEwController].

UIVIEw *rootVIEw = [[[self window] rootVIEwController] vIEw];[rootVIEw addSubvIEw:vIEw];

只要您使用具有根视图控制器的东西,这将起作用.只要rootVIEwController不是nil,这就可以工作.如果您正在使用原始的“基于视图”应用程序,那么通常最好选择另一个视图并将您的视图添加为其兄弟,而不是挖掘未记录的层次结构:

UIVIEw *sibling = ... (some other vIEw)[[sibling supervIEw] addSubvIEw:vIEw];
总结

以上是内存溢出为你收集整理的ipad – 使用insertSubview时的方向问题全部内容,希望文章能够帮你解决ipad – 使用insertSubview时的方向问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1085870.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存