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

     
  • 相关阅读:
    451. Sort Characters By Frequency
    424. Longest Repeating Character Replacement
    68. Text Justification
    44. Wildcard Matching
    160. Intersection of Two Linked Lists
    24. Swap Nodes in Pairs
    93. 递归实现组合型枚举
    98. 分形之城
    97. 约数之和
    96. 奇怪的汉诺塔
  • 原文地址:https://www.cnblogs.com/gcb999/p/3232475.html
Copyright © 2011-2022 走看看