表格默認選擇某行

-(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; }
相關文章
相關標籤/搜索