我忘了说,这只适用于iOS7 iPad。
您好,
我有一个View Controller,可以在代码中构建“Banner”视图,然后将它们添加到viewControllers View Hierarchy中。在程序控制下,可以随时显示0,1或2个横幅。
我决定使用父视图控制器来管理横幅并将子视图控制器添加到此父级。就显示而言,这一切都很好。如果一次只能看到一个“横幅”,它也可以正常工作,但是如果两个都显示,那么事件只会被发送到两个横幅中的一个 - 最后一个(在视图层次结构中)被添加。
最后一个横幅的事件通过确定,子视图控制器的事件也可以通过,但不是第一个启用的“横幅”,例如
e.g。
[myBanner1 enable]; [myBanner2 enable]; - 只有myBanner2的事件才会进入动作处理程序。
或
[myBanner2 enable]; [myBanner1 enable]; - 只有myBanner1的事件才能进入动作处理程序。
请参阅下面的View Controller的View Hierarchy转储。我也尝试删除“横幅容器视图”,只是将两个横幅视图添加到View Controller的.view属性,但同样的事情发生了。
任何人都知道我做错了什么?
非常感谢
ViewController.view - 通过initWithNibName:bundle从NIB加载 基本视图的子视图:0xba4e130 - 类:UIView标签:9999框架:0.000000,0.000000,768.000000,1024.000000
通过initWithNibName从NIB加载的视图:bundle: 子视图:0xba4e190 - 类:UILabel标签:9999框架:48.000000,26.000000,362.000000,21.000000
代码添加的横幅容器视图。 子视图:0xba41f30 - 类:UIView标签:1000帧:0.000000,0.000000,1024.000000,768.000000
Banner1 - 由代码添加。 子视图:0xbb5cd70 - 类:LTWBannerView标签:1001帧:0.000000,0.000000,1024.000000,768.000000 子视图:0xbb66d00 - 类:UIView标签:0帧:0.000000,20.000000,1024.000000,100.000000
Banner1项目 - 按代码添加。 Action被添加到UIButton对象中。 子视图:0xba34820 - 类:LTWBannerItemView标记:0帧:0.000000,0.000000,1024.000000,100.000000 子视图:0xbb80d80 - 类:UIImageView标签:1帧:0.000000,0.000000,1024.000000,100.000000 子视图:0xbb8d020 - 类:UIButton标签:2帧:0.000000,0.000000,1024.000000,100.000000 子视图:0xbb7c560 - 类:UIButtonLabel标签:0帧:440.000000,11.000000,144.000000,77.000000
Banner2 - 由代码添加。 Action被添加到UIButton对象中。 子视图:0xbb672d0 - 类:LTWBannerView标签:1002帧:0.000000,0.000000,1024.000000,768.000000 子视图:0xbb60cb0 - 类:UIView标签:0帧:0.000000,608.000000,1024.000000,160.000000 子视图:0xbb93910 - 类:LTWBannerItemView标记:0帧:0.000000,0.000000,256.000000,160.000000 子视图:0xbb8df30 - 类:UIImageView标签:1帧:0.000000,0.000000,256.000000,160.000000 子视图:0xbb8e980 - 类:UIButton标记:2帧:0.000000,0.000000,256.000000,160.000000 子视图:0xbb8dfb0 - 类:UIButtonLabel标签:0帧:43.000000,41.000000,170.000000,77.000000
SubViews of View: 0xbb89870 - class: LTWBannerItemView Tag: 0 Frame: 256.000000,0.000000,256.000000,160.000000
SubViews of View: 0xbb898e0 - class: UIImageView Tag: 1 Frame: 0.000000,0.000000,256.000000,160.000000
SubViews of View: 0xbb92370 - class: UIButton Tag: 2 Frame: 0.000000,0.000000,256.000000,160.000000
SubViews of View: 0xbb6c860 - class: UIButtonLabel Tag: 0 Frame: 50.000000,41.000000,156.000000,77.000000
SubViews of View: 0xbb8ff30 - class: LTWBannerItemView Tag: 0 Frame: 512.000000,0.000000,256.000000,160.000000
SubViews of View: 0xbb8bb00 - class: UIImageView Tag: 1 Frame: 0.000000,0.000000,256.000000,160.000000
SubViews of View: 0xbb8bbb0 - class: UIButton Tag: 2 Frame: 0.000000,0.000000,256.000000,160.000000
SubViews of View: 0xbb8bcd0 - class: UIButtonLabel Tag: 0 Frame: 29.000000,41.000000,197.000000,77.000000
SubViews of View: 0xbb87190 - class: LTWBannerItemView Tag: 0 Frame: 768.000000,0.000000,256.000000,160.000000
SubViews of View: 0xbb87230 - class: UIImageView Tag: 1 Frame: 0.000000,0.000000,256.000000,160.000000
SubViews of View: 0xbb872e0 - class: UIButton Tag: 2 Frame: 0.000000,0.000000,256.000000,160.000000
SubViews of View: 0xbb87420 - class: UIButtonLabel Tag: 0 Frame: 13.000000,41.000000,230.000000,77.000000
子视图控制器从NIB加载,并使用addChildViewController方法通过代码添加。 子视图:0xb741780 - 类:UIView标签:7777框架:0.000000,100.000000,1024.000000,508.000000 子视图:0xb738fd0 - 类:UILabel标签:7777框架:174.000000,100.000000,97.000000,21.000000 子视图:0xb7370b0 - 类:UIButton标签:0帧:212.000000,287.000000,110.000000,30.000000 子视图:0xb745180 - 类:UIButtonLabel标签:0帧:0.000000,6.000000,110.000000,18.000000