首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏hrscy

    在iOS中怎样创建可展开的Table View?(下)

    visibleRowsPerSection[indexPath.section][indexPath.row] } 虽然为了让我们的cell展开或合拢并没有太多代码,但是我们要将一步一步地走.现在我们已经有了点击行的真正索引 : NSIndexPath) { let indexOfTappedRow = visibleRowsPerSection[indexPath.section][indexPath.row] : NSIndexPath) { let indexOfTappedRow = visibleRowsPerSection[indexPath.section][indexPath.row] : NSIndexPath) { let indexOfTappedRow = visibleRowsPerSection[indexPath.section][indexPath.row] : NSIndexPath) { let indexOfTappedRow = visibleRowsPerSection[indexPath.section][indexPath.row]

    2.4K30发布于 2018-08-30
  • 来自专栏TechBox

    史上最全的iOS之访问自定义cell的textField.text的N种方法

    解决方法:自定义textField,给textField添加NSIndexPath类型的属性indexPath。我们这次给textField的indexPath赋值而不是tag。 有可能冲突 // cell.contentTextField.tag = indexPath.row; // 所以传递indexPath,相当于把section也传递给contentTextField cell.contentTextField.indexPath = indexPath; return cell; } 监听到通知后调用的方法 // 在这个方法中,我们就可以通过自定义 /** * indexPath属性用于区分不同的cell */ @property (strong, nonatomic) NSIndexPath *indexPath; @end 给自定义cell 作为协议方法的参数传进去 4>数据源方法cellForRowAtIndexPath:中对cell的indexPath赋值为当前的indexPath

    7.7K40发布于 2018-06-05
  • 来自专栏码客

    iOS UICollectionView的用法

    : IndexPath) -> UICollectionViewCell { let itemdata = colletcionData[indexPath.row]; let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MeCollectionViewCell", for: indexPath) as : IndexPath) -> CGSize { return CGSize(width: self.collectionView.frame.width/3, height: 100); } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { { OrderPicModel *model = self.tableData[indexPath.section][indexPath.row]; OrderPicsCollectionViewCell

    1.8K20发布于 2019-10-22
  • 来自专栏Python疯子

    Swift - 给TableView添加编辑功能(删除,插入)

    : UITableView, didSelectRowAt indexPath: IndexPath) { // 确定该分组的内容 let str = allNames[indexPath.section indexPath: IndexPath) -> UITableViewCellEditingStyle { if indexPath.section == 0 { return : IndexPath) -> String? : UITableView, didSelectRowAt indexPath: IndexPath) { // 确定该分组的内容 let str = allNames[indexPath.section indexPath: IndexPath) -> UITableViewCellEditingStyle { if indexPath.section == 0 { if tableView.isEditing

    4.1K20发布于 2018-09-06
  • 来自专栏TechBox

    (转)iOS开发之UICollectionViewController系列(二) :详解CollectionView各种回调

    NSLog(@"第%ld个Section上第%ld个Cell变为非高亮",indexPath.section ,indexPath.row); } } 4.Cell从非高亮变为高亮状态时回调用下面的方法 (@"第%ld个Section上第%ld个Cell取消选中",indexPath.section ,indexPath.row); } } 9.在Cell选中和取消选中时都会调用上面的方法来改变 NS_AVAILABLE_IOS(8_0){ NSLog(@"第%ld个Section上第%ld个Cell将要出现",indexPath.section ,indexPath.row); { NSLog(@"第%ld个Section上第%ld个Cell已经出现",indexPath.section ,indexPath.row); } /** * headerView NS_AVAILABLE_IOS(8_0){ NSLog(@"第%ld个Section上第%ld个扩展View将要出现",indexPath.section ,indexPath.row

    8.4K40发布于 2018-06-05
  • 来自专栏编程之路

    Swift纯代码 UICollectionView 分组显示、Cell圆角、选中变色

    SHomeHeader let title:String = headerArr[indexPath.section] as! ) { let cell = collectionView.cellForItemAtIndexPath(indexPath) cell!. : NSIndexPath) { let cell = collectionView.cellForItemAtIndexPath(indexPath) cell!. SHomeCell let title = dataArr[indexPath.row] cell.titleLabel?.text = title as? SHomeHeader let title:String = headerArr[indexPath.section] as!

    5.7K10发布于 2018-08-30
  • 来自专栏君赏技术博客

    托管UITableView多样式cell的第三方库ZHTableViewGroup

    通常在代理 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath *cell = [group cellWithIndexPath:indexPath]; return cell; } #pragma mark - UITableViewDelegate *group = [self.dataSource groupWithIndex:indexPath.section]; [group didSelectRowAtIndexPath:indexPath ) { NSLog(@"cell->%@,indexPath->%@",cell,indexPath); }; [group addTableViewCell:cellOne ) { NSLog(@"cell->%@,indexPath->%@",cell,indexPath); }; [group addTableViewCell:cellTwo

    98610发布于 2018-09-07
  • 来自专栏一“技”之长

    iOS UITableView代理方法详解 原

    )section; 设置某行是否可编辑 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath ; 设置某行是否可以被移动 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath ; - (NSIndexPath *)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath ; - (void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath; 移动特定的某行

    1.9K40发布于 2018-08-15
  • 来自专栏码客

    iOS按钮事件传參的二种方式

    经典方式 添加变量 var buttonPars:[Int:IndexPath] = [:]; 最常用的方式是直接给button设置tag cell.actionButton.addTarget(self *1000000 + indexPath.row; cell.actionButton.tag = tagNum; self.buttonPars[tagNum] = indexPath; 点击事件 @ objc func actionButtonClick(button:UIButton){ print("button.tag:\(button.tag)"); if let indexPath = self.buttonPars[button.tag]{ print("section:\(indexPath.section)"); print("row:\(indexPath.row NSIndexPath{ print("section:\(indexPath.section)"); print("row:\(indexPath.row)");

    96310发布于 2019-10-22
  • 来自专栏一“技”之长

    iOS流布局UICollectionView系列二——UICollectionView的代理方法

    则不能移动 - (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath (void)collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath

    2.5K20发布于 2018-08-16
  • 来自专栏非典型技术宅

    UITableView进阶:常用代理方法及属性1. 常用属性2. 进阶的常用代理方法

    indexPathsForSelectedRows:这里返回的是包含了indexPath的数组噢,因为要考虑到是多行选中的情况。 知道了这个属性之后,不要一说获取选中的cell的indexPath就只会用代理方法。& indexPathsForVisibleRows:这个方法其实并不太经常使用,但是很能提升逼格。 这个属性也是一个数组,它装着目前屏幕上可见的cell的indexPath集合。在做两级菜单联动的时候可能会需要用到。 2. 选中指定的cell //选中cell -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath + 1]; //插入cell NSIndexPath * inserIndex = [NSIndexPath indexPathForRow:indexPath.row

    1.5K20发布于 2018-06-28
  • 来自专栏君赏技术博客

    关于 ZHTableViewGroup 的设计之路

    , atIndexPath indexPath:IndexPath) -> UITableViewCell? ) // 获取重用的 Cell tableViewCell.configCell(cell: cell, indexPath: indexPath) // 配置 cell :IndexPath) -> ZHTableViewCell? , indexPath:IndexPath, customHeightCompletionHandle:ZHTableViewDataSourceCustomHeightCompletionHandle (cell: cell, indexPath: indexPath) // 告诉ZHTableViewCell 点击了 cell } 更对的信息请查看 ReadMe

    1.3K20发布于 2018-08-31
  • 来自专栏iOS开发干货分享

    iOS面向切面的TableView-AOPTableView

    是业务自己的indexPath,比如在列表可见的第五个位置,但是前面是有两个广告,在业务端的逻辑中该indexPath对应的位置是在第三个位置的,所以需要进行修正,返回正确的IndexPath,获取到对应位置的 ; if (aop_utils) { // 修复业务使用的indexPath为真实的indexPath indexPath = [aop_utils feedsIndexPathByUser 数组,sectionMap数据会用于处理真实数据和业务数据之间的映射 [1240] userIndexPathByFeeds方法使用sectionMap处理真实indexPath和业务indexPath 之间的变换 // 获取业务对应的indexPath,该方法的作用是进行indexPath,比如真实的indexPath为(0-5),前面插入了两个广告,会把indexPath修复为业务的indexPath ,该方法的作用是进行indexPath,比如真实的indexPath为(0-5),前面插入了两个广告,会把indexPath修复为业务的indexPath,也就是(0-3),如果该位置是广告的位置,那么返回

    1.3K00发布于 2019-05-11
  • 来自专栏大师级码师

    UICollectionView 的使用详解

    ]; cell.backgroundColor = [UIColor colorWithRed:((10 indexPath.row) / 255.0) green:((20 indexPath.row )/255.0) blue:((30 indexPath.row)/255.0) alpha:1.0f]; UILabel label = [[UILabel alloc] initWithFrame { UICollectionViewCell cell = (UICollectionViewCell )[collectionView cellForItemAtIndexPath:indexPath O(∩_∩)O~) cell.backgroundColor = [UIColor greenColor]; NSLog(@"item======%d",indexPath.item); NSLog (@"row=======%d",indexPath.row); NSLog(@"section===%d",indexPath.section); } //返回这个UICollectionView

    1.2K00发布于 2021-10-31
  • 来自专栏iOS开发攻城狮的集散地

    iOS UITableView获取特定位置的cell

    一、tableView双级联动 [菜单栏联动.gif] [UITableView双级联动.gif] 以上两种效果比较类似,实现的关键在于都是需要获得在滑动过程中滑动到tableView顶部的cell的indexPath 方案一:获得当前可见的所有cell,然后取可见cell数组中的第一个cell就是目标cell,再根据cell获得indexPath。 (@"滑到了第 %ld 组 %ld个",indexPath.section, indexPath.row); _currentIndexPath = [NSIndexPath indexPathForRow 偏移量的值实际上可以代表当时处于tableView顶部的cell在tableView上的相对位置, 那么我们就可以根据偏移量获得处于顶部的cell的indexPath。 NSLog(@"滑到了第 %ld 组 %ld个",indexPath.section, indexPath.row); _currentIndexPath = [NSIndexPath

    5.8K80发布于 2018-05-23
  • 来自专栏sktj

    IOS UITableViewCell 移动单元格位置

    Int{ 23 return customers.count 24 } 25 26 func tableView(_ tableView:UITableView, cellForRowAt indexPath text = customers[(indexPath as NSIndexPath).row] 38 return cell! 39 } 40 41 func tableView(_ tableView:UITableView, editingStyleForRowAt indexPathIndexPath) -> UITableViewCellEditingStyle :IndexPath) -> Bool { 46 return true 47 } 48 49 func tableView(_ tableView:UITableView, moveRowAt sourceIndexPath:IndexPath, to destinationIndexPath:IndexPath) { 50 let fromRow = (sourceIndexPath

    1.6K30发布于 2019-07-08
  • 来自专栏全栈程序员必看

    手机通讯录实现

    cell.nameLabel.text = [self.dic[self.titles [indexPath.section]][indexPath.row] objectForKey:@"name"] ; cell.ageLabel.text = [self.dic[self.titles [indexPath.section]][indexPath.row] objectForKey:@"age "]; cell.genderLabel.text = [self.dic[self.titles [indexPath.section]][indexPath.row] objectForKey :@"gender"]; cell.phoneNumberLabel.text = [self.dic[self.titles [indexPath.section]][indexPath.row { NSString *str = [self.dic[self.titles [indexPath.section]][indexPath.row] objectForKey:@"phoneNumber

    1.6K30编辑于 2022-07-06
  • 来自专栏sktj

    IOS UITableView 表格嵌套

    text = comments[(indexPath as NSIndexPath).row] 34 cell?.textLabel?. 38 } 39 40 func tableView(_ tableView:UITableView, heightForRowAt indexPathIndexPath) 41 -> CGFloat { 42 let subComments = comments[(indexPath as NSIndexPath).row] 43 let size = subComments.boundingRect text = articles[(indexPath as NSIndexPath).row/2] 43 cell1?.textLabel?. 56 } 57 } 58 59 func tableView(_ tableView:UITableView, heightForRowAt indexPathIndexPath) -> CGFloat

    1.4K40发布于 2019-07-08
  • 来自专栏慎独

    UITableView图文混排自动布局滑动优化实战

    { [_cellHeightsDic setObject:@(cell.height) forKey:indexPath]; } //设置高度 -(CGFloat)tableView:(UITableView objectForKey:indexPath]; if (height) return height.doubleValue; return 400; } -(CGFloat)tableView :(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ NSNumber *height = [_ { if ([tableView.indexPathsForVisibleRows indexOfObject:indexPath] == NSNotFound) { [ - indexPath.row < 6){ //剩下五个内容就立马开始刷新 [self loadMore]; } } 要注意的是控制好你的网络请求,保证一次只发起一次

    1.7K10发布于 2019-12-30
  • 来自专栏iOS底层原理

    iOS - 开发1年后对MVC新的理解

    { _cell = [tableView dequeueReusableCellWithIdentifier:addCellId forIndexPath:indexPath]; _cell.model = [APIManager manager].backPackModel[indexPath.row]; return _cell; } - (void)tableView ]; // 不合理 cell.model = self.dataArray[indexPath.row]; return cell; } 相信很多人都有写过这段代码 delegate :(NSInexPath *)indexPath { @synchronized (self) { if (indexPath.row < [SingleManage manage :)]) { [self.delegate didClickNum:self.numLabel indexPath:self.indexPath]; } } @end 那么最终

    1.5K71编辑于 2022-03-10
领券