iphone - Wepopover 控件中的 Uibutton

标签 iphone ios

<分区>

如何在 WEpopover Controller 中包含 uibutton,我想要在 WEpopover 中设置一组 3 个按钮,单击导航到其他 View 。我应该在 WEpopover Controller 中更改哪里?

最佳答案

在引擎盖下,WEPopover 的工作方式是向 mainWindow 添加一个 subview ,一个“容器”,它是 UIView 的子类,它位于您的 View 层次[1]。它向该容器添加给定 View Controller 的 view 属性。要知道如何调整该 View 的大小,它会向 View Controller 询问其 contentSizeForViewInPopover

因此,设置 3 个按钮的方式与为任何其他 View Controller 设置 3 个按钮的方式相同。唯一的区别是,在处理 3 个按钮的 UIViewController 子类中,您需要设置 contentSizeForViewInPopover

您可以在initviewDidLoad 中设置此属性。 (请记住将其添加到正确的 init 方法中——例如,如果您在 Storyboard中制作此 View Controller ,则不会调用 init 而是调用 initWithCoder :).

要实际添加按钮,您可能需要在 viewDidLoad 中使用如下代码:

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];

[1] 如果您向一个 View 询问其父 View ,然后向该 View 询问其父 View ,依此类推,您最终将到达 mainWindow

关于iphone - Wepopover 控件中的 Uibutton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13339232/

相关文章:

ios - cocos2d 3.0 滑动菜单网格

ios - 了解 iPhone 崩溃日志

ios - 在 ViewController 之间传递 UIImage

ios - 自定义委托(delegate)返回 nil 值

ios - Flex Mobile 4.6 应用程序不会在 IOS 上创建数据库?

ios - Swift 可选错误

c++ - Objective-C++调整大小实例 vector 不起作用

iphone - UIAlertView 像 "Turn On Location Services to allow maps to determine your location"。设置+取消

ios - 如何将源代码编译的 LLVM 与 Xcode 集成?

iphone - “MyAnnotation”可能无法响应 'initWithDictionary:'