在多个视图中显示 AdWhirl 广告时调整 UITableView 的大小
我正在尝试使用 AppDelegate 单例将 AdWhirl 集成到我的 iPhone 应用程序中,以便我可以在多个视图中使用相同的 AdWhirl 实例,但无法弄清楚如何调整这些视图中的表格大小。我使用的代码是:
in ...AppDelegate.h:
#import "AdWhirlView.h"
#import "AdWhirlDelegateProtocol.h"
@interface ...AppDelegate : NSObject <UIApplicationDelegate, AdWhirlDelegate>
AdWhirlView *awView;
...
@property (nonatomic, retain) AdWhirlView *awView;
in ...AppDelegate.m didFinishLaunchingWithOptions:
awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
也在 ...AppDelegate.m 我添加所需的委托方法
(NSString *)adWhirlApplicationKey...
(UIViewController *)viewControllerForPresentingModalView...
此代码允许我在多个视图中显示相同的广告但我不知道如何在显示广告时调整 UITableView 的大小以将其高度更改为更短,以便 UITableView 在没有广告时显示完整高度,或者在底部有广告时调整大小 屏幕。我将 UITableView 作为名为 myMainView 的 UIViewController 的子视图。
我尝试更改 UITableView 的 Nib 文件中的自动调整大小属性,以便在底部有一个可变间隔符,并使用以下代码将 AdWhirl 实例添加到视图中:
...AppDelegate * myDelegate = (...AppDelegate *)[[UIApplication sharedApplication] delegate];
[myDelegate.awView setFrame:CGRectMake(0, 480-20-44-50, 320, 50)];
[self.myMainView addSubview: myDelegate.awView];
这会在屏幕底部的正确位置显示广告,但是UITableView 没有调整大小。我应该怎么做?
I am trying to integrate AdWhirl into my iPhone app using an AppDelegate singleton so I can use the same AdWhirl instance across multiple views, but cannot figure out how to resize the tables in those views. The code I am using is:
in ...AppDelegate.h:
#import "AdWhirlView.h"
#import "AdWhirlDelegateProtocol.h"
@interface ...AppDelegate : NSObject <UIApplicationDelegate, AdWhirlDelegate>
AdWhirlView *awView;
...
@property (nonatomic, retain) AdWhirlView *awView;
in ...AppDelegate.m didFinishLaunchingWithOptions:
awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
also in ...AppDelegate.m I add the required delegate methods
(NSString *)adWhirlApplicationKey...
(UIViewController *)viewControllerForPresentingModalView...
This code allows me to display the same Ad across multiple views but I cannot figure out how to resize a UITableView to change its height to be shorter if an Ad is displaying, so that the UITableView either displays full height if there is no Ad, or is resized if there is an Ad at the bottom of the screen. I have the UITableView as a subview of a UIViewController called myMainView.
I tried changing the autosize properties in the Nib file for the UITableView to have a variable spacer at the bottom, and am adding the AdWhirl instance into the view with this code:
...AppDelegate * myDelegate = (...AppDelegate *)[[UIApplication sharedApplication] delegate];
[myDelegate.awView setFrame:CGRectMake(0, 480-20-44-50, 320, 50)];
[self.myMainView addSubview: myDelegate.awView];
This displays the Ad at the correct location at the bottom of the screen but the UITableView is not resizing. How should I be doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你必须创建一个带有嵌入式 UITableView 的 UIView 。我尝试过做类似的事情,这是我可以让它发挥作用的唯一方法。顶级 UITableView 会自动调整大小以占据整个屏幕。
只是扩展一下,您可能想在标头中声明一些内容,如下所示:
然后在实际实现中,您可以在需要时调整声明的 tablview 的大小,方法是:
I think you have to create a UIView with an embedded UITableView. I've tried to do something similar and this was the only way I could get it to work. A top-level UITableView is auto-resized to take up the entire screen.
Just expanding on that, you probably want to declare something in your header like so:
Then in your actual implementation, you can resize that declared tablview whenever you need to by doing: