如何将使用Interface Builder创建的视图显示为UIPopoverController? [英] How to display a view made with Interface Builder as a UIPopoverController?

查看:102
本文介绍了如何将使用Interface Builder创建的视图显示为UIPopoverController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Interface Builder中安静地设计我的视图,然后能够以UIPopoverController动态显示它们。

I'd like to design my views quietly in Interface Builder, then to be able to display them dynamically as an UIPopoverController.

我发现这个宝贵的教程但我不能将它扩展到我的需要。

I found this precious tutorial by Ray Wenderlich but I cannot extend it to my needs.

任何人都可以帮助我吗?

Anyone could help me ?

非常感谢。

推荐答案

以下是我通常的做法:假设我有一个父视图控制器,我想在其中呈现弹出窗口。
我声明一个popover控制器作为该VC的属性(@property(nonatomic,retain)UIPopoverController * popOverController;)

Here is how I usually do it: let's say I have a parent view controller in which I want to present the popover. I declare a popover controller as a property for that VC ( @property (nonatomic, retain) UIPopoverController* popOverController; )

用于呈现popover的代码一个新的视图控制器,我们称之为ViewController2,就是这个

The code for presenting a popover with a new view controller, let's call it ViewController2, would be this one

ViewController2* viewController2 = [[ViewController2 alloc] initWithNibName:@"ViewController2"  bundle:nil];

self.popOverController = [[UIPopoverController alloc] initWithContentViewController:viewController2];

popOverController.popoverContentSize = CGSizeMake(350, 216); //or whatever size you need

//this will present the view controller from the sender's frame, assuming this code is used inside an IBAction 
//and the popover's arrow will point down
[popOverController presentPopoverFromRect:[sender frame] inView:self.view  permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES]; 

[viewController2 release];

[popOverController release];

这几乎就是......
如果遇到任何问题,我会试着给你更多的信息。

That's pretty much it... If you run into any problems, I'll try to give you more infos.

PS我并不是说这是最好的方法,我对iO的经验不到一年,但我们通常在工作的地方做这件事

P.S. I am not claiming this is the best way to do it, I have less than an year of experience with iOs, but that's how we usually do it where I work

这篇关于如何将使用Interface Builder创建的视图显示为UIPopoverController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆