ios中 radioButton和DataPIcker,九宫格封装好使用
2013-08-29 17:29 甘超波 阅读(1875) 评论(0) 编辑 收藏 举报下载地址 http://pan.baidu.com/share/link?shareid=2894506499&uk=923776187
引用这几个文件
radiobutton。封装好单选按钮
DataPicker 封装好选择器
jiugongge 九宫格
commonButton 这个是公用的button.
nsCategory
使用方式
#import <UIKit/UIKit.h> #import "RadioButtonExt.h" @interface ViewController : UIViewController<RadioButtonExtDelegate> @end #import "ViewController.h" #import "DIYJGGView.h" #import "JSPresentCommonViewCtrl.h" #import "PresentView.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self RadioButtonSelect]; UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame=CGRectMake(0, 100, 50,50); [self.view addSubview:btn]; [btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]; } #pragma mark -radiobutton -(void)RadioButtonSelect{ NSArray *arr=@[@"标题1",@"标题2",@"标题3"]; RadioButtonExt *ext=[[RadioButtonExt alloc] initWithFrame:CGRectMake(0, 0, 320, 100) data:arr]; ext.delegate=self; ext.backgroundColor=[UIColor redColor]; [self.view addSubview:ext]; [ext release]; } #pragma mark -DataPicker -(void)click:(UIButton *)btn{ for (UIViewController *vc in self.childViewControllers) { [vc removeFromParentViewController]; } // JSPresentCommonViewCtrl *pre=[[JSPresentCommonViewCtrl alloc] initWithPresentType:1 WithDataArray:nil];//日期 JSPresentCommonViewCtrl *pre=[[JSPresentCommonViewCtrl alloc] initWithPresentType:0 WithDataArray:@[@"标题一",@"标题二"]];//选择 CGRect hrect,rect=self.view.bounds; pre.delegate=self; pre.method=@selector(selectData:); CGRectDivide(rect, &hrect, &rect, 260, CGRectMaxYEdge); [PresentView showWithSubView:pre.view subVFrame:hrect]; [self addChildViewController:pre]; [pre release]; } #pragma mark -单选按钮的代理方法 -(void)RadioButton:(RadioButtonExt *)rd from:(NSInteger)from to:(NSInteger)to{ NSLog(@"_from--%zi--->to-->%zi",from,to); } #pragma mark -DataPicker代理方法 -(void)selectData:(NSString *)selectStr{ [PresentView hidePresentSubView]; NSLog(@"__>%@",selectStr); } @end
目前我正在专注NLP,请立刻加微信/QQ号 546611623, 免费送你原创《NLP高级执行师》高清视频