大佬教程收集整理的这篇文章主要介绍了iOS中的UIPickerView内的UITableView,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
caratFromPicker = [[UIPickerView alloc] init]; caratTable = [[UITableView alloc]initWithFrame:caratFromPicker.frame style:UITableViewStylePlain]; caratTable.delegate = self; caratTable.datasource = self; caratTable.bounces = YES; UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithtitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@SELEctor(donE)]; UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0,self.view.frame.size.height-caratFromPicker.frame.size.height-50,self.view.frame.size.width,50)]; [toolBar setBarStyle:UIBarStyleBlackOpaque]; NSArray *toolbarItems = [NSArray arrayWithObjects:doneButton,nil]; [toolBar setItems:toolbarItems]; price1.inputView = caratFromPicker; price1.inputAccessoryView = toolBar; [caratFromPicker setDatasource: self]; [caratFromPicker setDelegate: self]; caratFromPicker.showsSelectionInDicator = YES;//loadFromPicker [caratFromPicker addSubview:caratTable];
并将uITableView委托实现为:
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [caratFromArray count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reusEIDentifier:CellIdentifier]; } tableView.separatorStyle = UITableViewCellSeparatorStyleNone; cell.textLabel.text = [caratFromArray objectATindex:indexPath.row]; return cell; }
以上是大佬教程为你收集整理的iOS中的UIPickerView内的UITableView全部内容,希望文章能够帮你解决iOS中的UIPickerView内的UITableView所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。