http://code4app.com/ios/Popover-View-in-iPhone/4fa931bd06f6e78d0f000000
下载这个,把工具类 导入到自己工程里面,他写的代码没有使用arc,如果你的代码用了arc,要去修改设置
引用类
#import "FPPopoverController.h"
#import "PopViewController.h"
@interface ViewController : UIViewController<popNextDeleage>{
FPPopoverController *basePop;//弹出视图
}
#import "PopViewController.h"
@interface ViewController : UIViewController<popNextDeleage>{
FPPopoverController *basePop;//弹出视图
}
---------
//发送
-(void)addMoreButton{
//navigationbar 右边的按钮
// UIBarButtonItem *moreButton = [[UIBarButtonItem alloc]initWithTitle:@"更多"
style:UIBarButtonItemStyleBordered target:self action:@selector(moreAction:)];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(270, 0, 44, 44)];
//button.backgroundColor = [UIColor redColor];
[button setTitle:@"more" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(moreAction:) forControlEvents:UIControlEventTouchUpInside];
[[UIBarButtonItem alloc] initWithCustomView:button];
}
pop.popDeleage = self;//设置deleage(谁实现了delegate方法就指定给谁)
basePop = [[FPPopoverController alloc] initWithViewController:pop];
basePop.tint = FPPopoverLightGrayTint;
basePop.arrowDirection = FPPopoverArrowDirectionAny;
[basePop presentPopoverFromView:sender];
-(void)addMoreButton{
//navigationbar 右边的按钮
// UIBarButtonItem *moreButton = [[UIBarButtonItem alloc]initWithTitle:@"更多"
style:UIBarButtonItemStyleBordered target:self action:@selector(moreAction:)];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(270, 0, 44, 44)];
//button.backgroundColor = [UIColor redColor];
[button setTitle:@"more" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(moreAction:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithCustomView:button];
}
-(
void)moreAction:(UIButton *)sender{[
self pop:sender];}
-(
void)pop:(id)sender{PopViewController *pop = [[PopViewController alloc] init];
pop.popDeleage = self;//设置deleage(谁实现了delegate方法就指定给谁)
basePop = [[FPPopoverController alloc] initWithViewController:pop];
basePop.tint = FPPopoverLightGrayTint;
basePop.arrowDirection = FPPopoverArrowDirectionAny;
[basePop presentPopoverFromView:sender];
}
------PopViewController.h-(在这个类里面设置弹出视图)------