想要使用muliple笔尖用于不同的iphone接口方向

想要使用muliple笔尖用于不同的iphone接口方向,第1张

概述我有一个情况,我创建了两个不同的笔尖,一个在纵向模式,另一个在横向模式.我在视图中有很多设计,所以我不得不选择两个不同的笔尖.现在,我想在界面旋转时切换笔尖 common viewController 这样我就可以保留填充值和视图中控件的状态. 现在我正在使用 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientatio 我有一个情况,我创建了两个不同的笔尖,一个在纵向模式,另一个在横向模式.我在视图中有很多设计,所以我不得不选择两个不同的笔尖.现在,我想在界面旋转时切换笔尖

common vIEwController

这样我就可以保留填充值和视图中控件的状态.

现在我正在使用

- (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation {// OverrIDe to allow orIEntations other than the default portrait orIEntation.if(interfaceOrIEntation == UIInterfaceOrIEntationLandscapeleft || interfaceOrIEntation == UIInterfaceOrIEntationLandscapeRight ){    [self initWithNibname:@"LandscapeNib" bundle:nil];}else if(interfaceOrIEntation == UIInterfaceOrIEntationPortrait || interfaceOrIEntation == UIInterfaceOrIEntationPortraitUpsIDeDown){    [self initWithNibname:@"PortraitNib" bundle:nil];}return YES;

}

但它没有改变Nib,它显示了初始加载的笔尖.我猜它是加载但没有显示,因为初始笔尖已经显示,不会被删除.我无法找到使用通用视图控制器处理多个笔尖的解决方案,以便我可以轻松处理控件的功能?

解决方法 您应该为横向模式创建一个特殊的视图控制器,并在设备旋转时以模态方式显示它.要在设备旋转时收到通知,请注册UIDeviceOrIEntationDIDChangeNotification通知.

对于需要以纵向和横向呈现不同的复杂视图,这是Apple实施它的推荐方法.阅读此处了解更多详情:

http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/BasicViewControllers/BasicViewControllers.html#//apple_ref/doc/uid/TP40007457-CH101-SW26

这是Apple文档的一个片段.在init或awakeFromNib中注册通知:

[[UIDevice currentDevice] beginGeneratingDeviceOrIEntationNotifications];   [[NSNotificationCenter defaultCenter] addobserver:self                             selector:@selector(orIEntationChanged:)                             name:UIDeviceOrIEntationDIDChangeNotification                             object:nil];

并且在orIEntationChanged中,根据当前的旋转,以模态方式呈现您的横向视图控制器,或者将其关闭:

- (voID)orIEntationChanged:(NSNotification *)notification{    UIDeviceOrIEntation deviceOrIEntation = [UIDevice currentDevice].orIEntation;    if (UIDeviceOrIEntationIsLandscape(deviceOrIEntation) &&        !isShowingLandscapeVIEw)    {        [self presentModalVIEwController:self.landscapeVIEwController                                animated:YES];        isShowingLandscapeVIEw = YES;    }    else if (deviceOrIEntation == UIDeviceOrIEntationPortrait &&             isShowingLandscapeVIEw)    {        [self dismissModalVIEwControllerAnimated:YES];        isShowingLandscapeVIEw = NO;    }}
总结

以上是内存溢出为你收集整理的想要使用muliple笔尖用于不同的iphone接口方向全部内容,希望文章能够帮你解决想要使用muliple笔尖用于不同的iphone接口方向所遇到的程序开发问题。

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

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

原文地址: https://outofmemory.cn/web/1082620.html

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

发表评论

登录后才能评论

评论列表(0条)

保存