zoukankan      html  css  js  c++  java
  • ios中LeveyPopListView 弹出view的用法

     下载地址 https://github.com/levey/LeveyPopListView 是arc,  如果是非arc项目要设置一下 

    方法

    选中工程->TARGETS->相应的target然后选中右侧的“Build Phases”,向下就找到“Compile Sources”了。
    如何在未使用arc的工程中引入一个使用了arc特性的文件:对相应的文件添加:-fobjc-arc参数

    #import <UIKit/UIKit.h>
    #import "LeveyPopListView.h"
    
    @interface MyViewController : UIViewController<LeveyPopListViewDelegate>
    
    @end

     

    
    

    #import "MyViewController.h"

    
    

     

    
    

    @interfaceMyViewController ()

    
    

    {

    
    

        UILabel *lb;

    
    

    }

    
    

    @property(nonatomic,retain)NSArray *options;

    
    

     

    
    

    @end

    
    

     

    
    

    @implementation MyViewController

    
    

     

    
    

     

    
    

     

    
    

    - (void)viewDidLoad

    
    

    {

    
    

        [superviewDidLoad];

    
    

        self.view.backgroundColor=[UIColorwhiteColor];

    
    

        

    
    

        //数据源

    
    

       self.options = [NSArrayarrayWithObjects:

    
    

                    [NSDictionarydictionaryWithObjectsAndKeys:[UIImageimageNamed:@"facebook.png"],@"img",@"Facebook",@"text", nil],

    
    

                    [NSDictionarydictionaryWithObjectsAndKeys:[UIImageimageNamed:@"twitter.png"],@"img",@"Twitter",@"text", nil],

    
    

                    [NSDictionarydictionaryWithObjectsAndKeys:[UIImageimageNamed:@"tumblr.png"],@"img",@"Tumblr",@"text", nil],

    
    

                    [NSDictionarydictionaryWithObjectsAndKeys:[UIImageimageNamed:@"google-plus.png"],@"img",@"Google+",@"text", nil],

    
    

                    [NSDictionarydictionaryWithObjectsAndKeys:[UIImageimageNamed:@"linkedin.png"],@"img",@"LinkedIn",@"text", nil],

    
    

                    [NSDictionarydictionaryWithObjectsAndKeys:[UIImageimageNamed:@"pinterest.png"],@"img",@"Pinterest",@"text", nil],

    
    

                    [NSDictionarydictionaryWithObjectsAndKeys:[UIImageimageNamed:@"dribbble.png"],@"img",@"Dribbble",@"text", nil],

    
    

                    [NSDictionarydictionaryWithObjectsAndKeys:[UIImageimageNamed:@"deviant-art.png"],@"img",@"deviantArt",@"text", nil],

    
    

                    nil];

    
    

        UIButton *btn=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];

    
    

        btn.frame=CGRectMake(0, 0, 100, 100);

    
    

        

    
    

        lb=[[UILabelalloc] initWithFrame:CGRectMake(100, 100, 200,50)];

    
    

        lb.backgroundColor=[UIColorclearColor];

    
    

        [lbsetTextColor:[UIColorredColor]];

    
    

        [self.viewaddSubview:lb];

    
    

        [lbrelease];

    
    

        

    
    

        [btn setTitle:@"TEST"forState:UIControlStateNormal];

    
    

        [btn addTarget:selfaction:@selector(click) forControlEvents:UIControlEventTouchUpInside];

    
    

        [self.viewaddSubview:btn];

    
    

    // Do any additional setup after loading the view.

    
    

    }

    
    

     

    
    

    -(void)click{

    
    

        

    
    

        //创建 LeveyPopListView

    
    

        LeveyPopListView *lv=[[LeveyPopListViewalloc] initWithTitle:@"展示"options:self.options];

    
    

        

    
    

        lv.delegate=self;

    
    

        

    
    

        [lv showInView:self.viewanimated:YES];

    
    

        [lv release];

    
    

    }

    
    

     

    
    

    #pragma  mark 代理方法

    
    

    - (void)leveyPopListView:(LeveyPopListView *)popListView didSelectedIndex:(NSInteger)anIndex{

    
    

        NSLog(@"%zi",anIndex);

    
    

        NSString *key=[self.options[anIndex] allValues][1];

    
    

        lb.text=[NSStringstringWithFormat:@"返回数据-->%@",key];

    
    

    }

    
    

    - (void)leveyPopListViewDidCancel{

    
    

        NSLog(@"取消");

    
    

    }

    
    

     

    
    

     

    
    

    @end

     
  • 相关阅读:
    shellshock溢出攻击
    内核编译与系统调用
    模块与系统调用
    20199315《Linux内核原理与分析》第十二周作业
    20199315《Linux内核原理与分析》第十一周作业
    Linux下的静态链接库和动态链接库
    2019-2020-1 20199315《Linux内核原理与分析》第九周作业
    2019-2020-1 20199315 《Linux内核原理与分析》 第八周作业
    2019-2020-1 20199315《Linux内核原理与分析》第七周作业
    2019-2020-1 20199315《Linux内核原理与分析》第六周作业
  • 原文地址:https://www.cnblogs.com/gcb999/p/3232475.html
Copyright © 2011-2022 走看看