首页 > 代码库 > 表格默认选择某行

表格默认选择某行

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ProductTypeCell *mProductTypeCell = [tableView dequeueReusableCellWithIdentifier:productTypeindterfier];
    mProductTypeCell.selectedBackgroundView = [[UIView alloc] initWithFrame:mProductTypeCell.frame];
    mProductTypeCell.selectedBackgroundView.backgroundColor  = [UIColor whiteColor];
//    另外修改字体的颜色
    mProductTypeCell.typeLable.highlightedTextColor = RGB(0x00bdbe);
    ProductListModel *mProductListModel = _dataArray[indexPath.row];
    mProductTypeCell.typeLable.text = [NSString stringWithFormat:@"%@",mProductListModel.productTypeName];
//默认中    
[_productTableView selectRowAtIndexPath:[NSIndexPath indexPathForItem:
0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop]; if ([_productTableView.delegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]) {
[_productTableView.
delegate tableView:_productTableView didSelectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]]; } return mProductTypeCell; }

 

表格默认选择某行