gpt4 book ai didi

iphone - 以编程方式设置 UIPopOver View 的标题

转载 作者:太空狗 更新时间:2023-10-30 03:36:21 27 4
gpt4 key购买 nike

如何以编程方式设置 UIPopOver View 的标题?

我找到了一些示例代码,但无法设置标题。

myView *theView = [[myView alloc] initWithNibName:@"myView" 
bundle:nil];
UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:theView];
[aPopover setDelegate:self];
[aPopover setPopoverContentSize:CGSizeMake(320, 320) animated:YES];

[theView setPopover:aPopover];
[theView release];

[self.popoverController presentPopoverFromRect:CGRectMake(510,370,0,0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

最佳答案

您需要将 View Controller 包装在 UINavigationCotnroller 中,这将为 View Controller 添加一个带有适当标题的导航栏。像这样:

UINavigationController *container =
[[[UINavigationController alloc] initWithRootViewController:viewController] autorelease];

然后只需初始化您的弹出窗口以使用 container 代替并像往常一样显示它。

关于iphone - 以编程方式设置 UIPopOver View 的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3296697/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com