<i id='ui8HB'><tr id='ui8HB'><dt id='ui8HB'><q id='ui8HB'><span id='ui8HB'><b id='ui8HB'><form id='ui8HB'><ins id='ui8HB'></ins><ul id='ui8HB'></ul><sub id='ui8HB'></sub></form><legend id='ui8HB'></legend><bdo id='ui8HB'><pre id='ui8HB'><center id='ui8HB'></center></pre></bdo></b><th id='ui8HB'></th></span></q></dt></tr></i><div id='ui8HB'><tfoot id='ui8HB'></tfoot><dl id='ui8HB'><fieldset id='ui8HB'></fieldset></dl></div>
    <tfoot id='ui8HB'></tfoot>
  1. <small id='ui8HB'></small><noframes id='ui8HB'>

  2. <legend id='ui8HB'><style id='ui8HB'><dir id='ui8HB'><q id='ui8HB'></q></dir></style></legend>

        <bdo id='ui8HB'></bdo><ul id='ui8HB'></ul>
    1. iPhone 应用中的全局 ADBannerView

      global ADBannerView in iPhone app(iPhone 应用中的全局 ADBannerView)

      <small id='1HGB0'></small><noframes id='1HGB0'>

        <tfoot id='1HGB0'></tfoot>
          <i id='1HGB0'><tr id='1HGB0'><dt id='1HGB0'><q id='1HGB0'><span id='1HGB0'><b id='1HGB0'><form id='1HGB0'><ins id='1HGB0'></ins><ul id='1HGB0'></ul><sub id='1HGB0'></sub></form><legend id='1HGB0'></legend><bdo id='1HGB0'><pre id='1HGB0'><center id='1HGB0'></center></pre></bdo></b><th id='1HGB0'></th></span></q></dt></tr></i><div id='1HGB0'><tfoot id='1HGB0'></tfoot><dl id='1HGB0'><fieldset id='1HGB0'></fieldset></dl></div>
            <legend id='1HGB0'><style id='1HGB0'><dir id='1HGB0'><q id='1HGB0'></q></dir></style></legend>
              <bdo id='1HGB0'></bdo><ul id='1HGB0'></ul>

                  <tbody id='1HGB0'></tbody>
              • 本文介绍了iPhone 应用中的全局 ADBannerView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                是否可以使用标准的 UINavigationController 根应用程序,在屏幕底部、视图层次结构下方显示单个 ADBannerView?也就是说,在不修改可以推送到根 UINavigationController 的每个视图控制器/视图的情况下,我可以让全局 ADBannerView 可见吗?

                Is it possible with a standard UINavigationController-rooted app, to have a single ADBannerView visible at the bottom of the screen, below the view hierarchy? That is, without modifying each view-controller/view that can be pushed to the root UINavigationController, can I have a global ADBannerView be visible?

                我不确定如何在 IB 或代码中进行设置.帮忙?

                I'm not sure how to set this up, either in IB or in code. Help?

                我看到类似的问题,但答案含糊不清.我正在寻找一个具体的例子.

                I see similar questions with vague answers. I'm looking for a concrete example.

                推荐答案

                在 iOS5+ 中更好的方法可能是使用视图控制器包含.也就是说,制作一个包含您的广告和应用程序控制器(导航、标签等)的根控制器.

                我想出了一个办法.这是我所做的:

                I figured out a way to do this. Here is what I did:

                在我的第一次尝试中,我创建了一个名为 AdBannerController 的新视图控制器.对于它的视图,我创建了一个全屏视图和两个子视图.第一个子视图(contentView)用于常规内容,第二个是 AdBannerView.我使用这个视图控制器的一个实例作为与应用程序窗口关联的视图控制器( [window addSubview: adBannerController.view] ).然后我将我的 UINavigationController.view 添加为 adBannerController.view 的子视图:[adBannerController.contentView addSubview: navigationController.view].

                For my first attempt I created a new view controller called AdBannerController. For its view I created a full-screen view and two subviews. The first subview (contentView) is for regular content, the second is the AdBannerView. I used an instance of this view controller as the view controller associated with the app window ( [window addSubview: adBannerController.view] ). Then I added my UINavigationController.view as a subview of adBannerController.view: [adBannerController.contentView addSubview: navigationController.view].

                除了推送到 UINavigationController 的视图控制器从未调用过他们的 will/did-load/unload 方法之外,这主要是有效的.嘘.我在一些地方读到,这是 UINavigationController 视图不是应用程序窗口的直接后代的症状.

                This mostly worked except that viewcontrollers pushed to the UINavigationController never got their will/did-load/unload methods called. Shucks. I read in a few places that this is a symptom of the UINavigationController view not being a direct descendant of the app window.

                对于我的第二次尝试,我采用了相同的 AdBannerController,并从 UINavigationController 派生了它.这一次,我在 loadView 中做了以下操作:

                For my second attempt I took the same AdBannerController and derived it from UINavigationController. This time, I did the following in loadView:

                - (void)loadView
                {
                    [super loadView];
                
                    _contentView = [self.view retain];
                
                    self.view = [[[UIView alloc] initWithFrame: _contentView.frame] autorelease];
                
                    [self.view addSubview: _contentView];
                
                    _adView = [[ADBannerView alloc] initWithFrame: CGRectMake(0, _contentView.bounds.size.height, 320, 50)];
                    _adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
                    _adView.delegate = self;
                
                    [self.view addSubview: _adView]; 
                
                    /* for visual debugging of view layout
                    [[_mainView layer] setCornerRadius: 6.0];
                    [[_mainView layer] setMasksToBounds: YES];
                    [[_mainView layer] setBorderWidth: 1.5];
                    [[_mainView layer] setBorderColor: [[UIColor grayColor] CGColor]];  
                     */
                }
                

                注意发生了什么 - 我让超类 UINavigationController 构建其常规的内容"视图,但我将其换掉并替换为我自己的视图,该视图是内容和广告视图的容器.

                Notice what happens - I let the superclass UINavigationController construct its regular "content" view, but I swap it out and replace it with my own view which is a container for both the content and ad views.

                这很好用.我也在使用three20,并且需要做一些事情才能使用该设置,但还不错.

                This works pretty well. I'm also using three20 and there were a few things required to make this work with that setup, but not too bad.

                我希望这对某人有帮助!

                I hope this helps someone!

                这篇关于iPhone 应用中的全局 ADBannerView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                UINavigationController inside a UITabBarController inside a UISplitViewController presented modally on iPhone(UISplitViewController 内的 UITabBarController 内的 UINavigationController 以模态方式呈现在 iPhone 上) - IT屋-程序员软件开发技术分
                ViewController in UINavigationController orientation change(UINavigationController 中的 ViewController 方向更改)
                Custom back button in UINavigationController(UINavigationController 中的自定义后退按钮)
                How to get the previous viewcontroller that pushed my current view(如何获取推送我当前视图的上一个视图控制器)
                The correct way to set a light status bar text color in iOS 7 based on different ViewControllers(iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法)
                Show UITabBar when UIViewController pushed(推送 UIViewController 时显示 UITabBar)

                      <tbody id='1ITM2'></tbody>
                    • <legend id='1ITM2'><style id='1ITM2'><dir id='1ITM2'><q id='1ITM2'></q></dir></style></legend>
                        <bdo id='1ITM2'></bdo><ul id='1ITM2'></ul>
                        <tfoot id='1ITM2'></tfoot>

                        <small id='1ITM2'></small><noframes id='1ITM2'>

                        <i id='1ITM2'><tr id='1ITM2'><dt id='1ITM2'><q id='1ITM2'><span id='1ITM2'><b id='1ITM2'><form id='1ITM2'><ins id='1ITM2'></ins><ul id='1ITM2'></ul><sub id='1ITM2'></sub></form><legend id='1ITM2'></legend><bdo id='1ITM2'><pre id='1ITM2'><center id='1ITM2'></center></pre></bdo></b><th id='1ITM2'></th></span></q></dt></tr></i><div id='1ITM2'><tfoot id='1ITM2'></tfoot><dl id='1ITM2'><fieldset id='1ITM2'></fieldset></dl></div>