【问题标题】:Setting contentSizeForViewInPopover property of UINavigationController seems to fail设置 UINavigationController 的 contentSizeForViewInPopover 属性似乎失败
【发布时间】:2013-04-02 15:37:29
【问题描述】:

如以下代码所示,设置 UINavigationController 对象的 contentSizeForViewInPopover 属性似乎失败了。这种行为是否符合预期?我犯了一些错误吗?谢谢。

(使用 XCode 4.6,Mac OS X v 10.7.5)

// Make a plain view controller.
UIViewController * root = [[UIViewController alloc] init];

// Make a navigation controller whose root view is the plain
// view controller from above.
UINavigationController * nav =
    [[UINavigationController alloc] initWithRootViewController: root];

// Set the content size for popover to 100 x 100.
nav.contentSizeForViewInPopover = CGSizeMake(100, 100);

// Print out the property that we just set.
NSLog (@"size = (%f, %f)",
       nav.contentSizeForViewInPopover.width,
       nav.contentSizeForViewInPopover.height);

// It prints: size = (320.000000, 1144.000000)

【问题讨论】:

    标签: ios properties uinavigationcontroller popover contentsize


    【解决方案1】:

    更改导航控制器的contentSizeForViewInPopover 不是一个好主意。改为在root 上更改它。 UINavigationController 通过添加其导航栏所需的大小,自动从其当前控制器计算其大小。

    【讨论】:

    • 谢谢苏丹。通过更多的实验,我发现导航控制器从导航堆栈顶部的任何内容中获取其 contentSizeForViewInPopover,正如您所说。
    猜你喜欢
    • 2011-12-23
    • 1970-01-01
    • 1970-01-01
    • 2021-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多