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

     
  • 相关阅读:
    在浏览器上实时显示机械臂运动,treeJS机械臂运动
    Centrifuge在vue中基础使用,soket通讯
    Mxgrapheditor编辑器汉化
    ADrive在线网络存储(50G超大免费空间)
    Gmail邮箱为电脑减负,GMailStore网络硬盘开始亮剑
    全球最受欢迎的100个网站 [转载]
    第一次亲密接触读后感(转)
    Weaver博客地址更改通知 (http://blog.sina.com.cn/weaver)
    Javascript技巧(230个)[转载]
    教师精彩课堂用语50句
  • 原文地址:https://www.cnblogs.com/gcb999/p/3232475.html
Copyright © 2011-2022 走看看