国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

iOS自定義選擇框代碼分享

2019-10-21 18:47:47
字體:
來源:轉載
供稿:網友

本文實例為大家分享了iOS自定義選擇框的具體代碼,供大家參考,具體內容如下

效果圖:

iOS,選擇框

工程圖:

iOS,選擇框

代碼:

RootViewController.h

#import <UIKit/UIKit.h>#import "CYCustomMultiSelectPickerView.h" @interface RootViewController : UIViewController<CYCustomMultiSelectPickerViewDelegate>{ CYCustomMultiSelectPickerView *multiPickerView; UILabel *pickLabel;}@end

RootViewController.m

#import "RootViewController.h"@interface RootViewController ()@end@implementation RootViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) {  // Custom initialization } return self;}- (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view.   self.title=@"ALPickerView";  pickLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 100, 100, 50)]; pickLabel.backgroundColor=[UIColor orangeColor]; pickLabel.textAlignment=NSTextAlignmentCenter; [self.view addSubview:pickLabel];}//隨意點擊任意處,彈出選擇框-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [self initPickerView];}-(void)initPickerView{ for (UIView *view in self.view.subviews) {  if ([view isKindOfClass:[CYCustomMultiSelectPickerView class]]) {   [view removeFromSuperview];  } }  multiPickerView = [[CYCustomMultiSelectPickerView alloc] initWithFrame:CGRectMake(0,[UIScreen mainScreen].bounds.size.height - 260-20, 320, 260+44)]; multiPickerView.backgroundColor = [UIColor clearColor]; multiPickerView.entriesArray = [NSMutableArray arrayWithObjects:@"one",@"two",@"three",@"four",@"five",@"six",@"seven", nil]; multiPickerView.entriesSelectedArray = [NSMutableArray arrayWithObject:@"one"]; multiPickerView.multiPickerDelegate = self;  [self.view addSubview:multiPickerView]; [multiPickerView pickerShow];}#pragma -mark -picker delegate//點擊確定要執行的操作-(void)returnChoosedPickerString:(NSMutableArray *)selectedEntriesArr{ NSLog(@"returnChoosedPickerString");  NSMutableArray* newArray = [NSMutableArray array];  for (NSString* str in selectedEntriesArr) {    [newArray addObject:str]; } NSString *endStr = [newArray componentsJoinedByString:@","];  pickLabel.text=endStr; }- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到IOS開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平远县| 永泰县| 乾安县| 巴彦县| 临沂市| 江城| 云龙县| 南召县| 苗栗县| 嘉善县| 义乌市| 新民市| 光泽县| 电白县| 墨脱县| 新龙县| 越西县| 无锡市| 沈阳市| 毕节市| 平谷区| 社会| 江口县| 赞皇县| 仪征市| 水城县| 民丰县| 突泉县| 财经| 运城市| 兴国县| 和田县| 福泉市| 武穴市| 石嘴山市| 易门县| 图木舒克市| 孟州市| 西青区| 额济纳旗| 淮阳县|