ios – 如何使用导航控制器创建静态子视图?

ios – 如何使用导航控制器创建静态子视图?,第1张

概述我创建了一个带有一堆视图控制器的导航控制器. 我想在底部添加一个子视图,当用户在这一堆视图之间导航时,该子视图保持静态(不移动). 与某些应用程序一样,底部有一个“广告栏”. 我怎样才能做到这一点? 如果我理解正确,这就是你想要的: 您可以通过创建一个包含UINavigationController的自定义UIViewController来实现此目的.创建一个名为“CustomViewContro 我创建了一个带有一堆视图控制器的导航控制器.

我想在底部添加一个子视图,当用户在这一堆视图之间导航时,该子视图保持静态(不移动).

与某些应用程序一样,底部有一个“广告栏”.

我怎样才能做到这一点?

解决方法 如果我理解正确,这就是你想要的:

您可以通过创建一个包含UINavigationController的自定义UIVIEwController来实现此目的.创建一个名为“CustomVIEwController”的新类,并粘贴以下代码:

接口

#@R_404_5565@ <UIKit/UIKit.h>@interface CustomVIEwController : UIVIEwController- (ID)initWithVIEwController:(UIVIEwController*)vIEwController bottomVIEw:(UIVIEw*)bottomVIEw;@end

执行:

#@R_404_5565@ "CustomVIEwController.h"@implementation CustomVIEwController- (ID)initWithVIEwController:(UIVIEwController*)vIEwController bottomVIEw:(UIVIEw*)bottomVIEw{    self = [super init];    if (self) {        //  Set up vIEw size for navigationController; use full bounds minus 60pt at the bottom        CGRect navigationControllerFrame = self.vIEw.bounds;        navigationControllerFrame.size.height -= 60;        vIEwController.vIEw.frame = navigationControllerFrame;        //  Set up vIEw size for bottomVIEw        CGRect bottomVIEwFrame = CGRectMake(0,self.vIEw.bounds.size.height-60,self.vIEw.bounds.size.wIDth,60);        bottomVIEw.frame = bottomVIEwFrame;        //  Enable autoresizing for both the navigationController and the bottomVIEw        vIEwController.vIEw.autoresizingMask = UIVIEwautoresizingFlexibleWIDth | UIVIEwautoresizingFlexibleHeight;        bottomVIEw.autoresizingMask = UIVIEwautoresizingFlexibleWIDth | UIVIEwautoresizingFlexibletopmargin;        //  Add vIEws as subvIEws to the current vIEw        [self.vIEw addSubvIEw:vIEwController.vIEw];        [self.vIEw addSubvIEw:bottomVIEw];    }    return self;}@end

现在使用CustomVIEwController:

UIVIEw *myBottomVIEw = [[UIVIEw alloc] initWithFrame:CGRectMake(0,200,100)];myBottomVIEw.backgroundcolor = [UIcolor redcolor];CustomVIEwController *customVIEwController = [[CustomVIEwController alloc] initWithVIEwController:<yourNavigationController> bottomVIEw:myVIEw];
总结

以上是内存溢出为你收集整理的ios – 如何使用导航控制器创建静态子视图?全部内容,希望文章能够帮你解决ios – 如何使用导航控制器创建静态子视图?所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存