现在的位置: 首页 > 综合 > 正文

iPhone弹出视图

2017年12月09日 ⁄ 综合 ⁄ 共 1443字 ⁄ 字号 评论关闭

http://code4app.com/ios/Popover-View-in-iPhone/4fa931bd06f6e78d0f000000 
下载这个,把工具类 导入到自己工程里面,他写的代码没有使用arc,如果你的代码用了arc,要去修改设置


引用类
#import "FPPopoverController.h"
#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 allocinitWithFrame:CGRectMake(27004444)];
    
//button.backgroundColor = [UIColor redColor];
    [button 
setTitle:@"more" forState:UIControlStateNormal];
    [button 
setTitleColor:[UIColor blackColorforState:UIControlStateNormal];
    [button 
addTarget:self action:@selector(moreAction:) forControlEvents:UIControlEventTouchUpInside];

    self.navigationItem.rightBarButtonItem =
[[
UIBarButtonItem allocinitWithCustomView:button];
    
    
    
    
}

-(void)moreAction:(UIButton *)sender{

    [self pop:sender];
    

}

-(void)pop:(id)sender{

    PopViewController *pop = [[PopViewController allocinit];
    pop.
popDeleage = self;//设置deleage(谁实现了delegate方法就指定给谁)
    
basePop = [[FPPopoverController allocinitWithViewController:pop];
    
basePop.tint = FPPopoverLightGrayTint;
    
basePop.arrowDirection = FPPopoverArrowDirectionAny;
    [
basePop presentPopoverFromView:sender];

}





------PopViewController.h-(在这个类里面设置弹出视图)------








抱歉!评论已关闭.