第一步。新建一个pad project
并创建两个视图xib类如下:
第二步。在View2.xib中写好你的代码或者拖控件
第三步。View1.h中添加:
1.#import "View2.h"
2.<UIPopoverControllerDelegate>
3.- (IBAction)showView2:(id)sender;
第四步。View1.m中添加下面代码:
- (IBAction)showView2:(id)sender
{
View2 *two = [[View2 alloc] init];
UIPopoverController *temp = [[UIPopoverController alloc] initWithContentViewController:two];
[temp setDelegate:self];
[temp presentPopoverFromRect:CGRectMake(0, 0, 50, 500) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[temp setPopoverContentSize:CGSizeMake(540, 600)];
}
第五步。在View1.xib中连接按钮方法
第六步。点击运行,OK啦~~