TableView

#pragma mark ---- TableView开始

//////////////////////////////////////////
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  return 1;

}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [JDList count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   return 88;
}


// Customize the appearance of table view cells.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"ListCell";
    ListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[ListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    cell = [[[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil] lastObject];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
   
    return cell;  

}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark ---- TableView结束



不等高

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.frame.size.height;
}

直接cell.xib

  NSArray* nibView =  [[NSBundle mainBundle] loadNibNamed:@"ManagerTileCell" owner:nil options:nil];
    UITableViewCell *cell = [nibView objectAtIndex:0];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;


self.tableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];


设置Cell不可点击

self.m_table.allowsSelection =NO;



设置Cell点击后不变色

cell.selectionStyle =UITableViewCellSelectionStyleNone;


////////滑动删除
//先要设Cell可编辑
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.section==0)
        return NO;
    else
        return YES;
}

//定义编辑样式
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleDelete;
}

//进入编辑模式,按下出现的编辑按钮后
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    id obj = [self.dataList objectAtIndex:indexPath.row];
    if([obj isKindOfClass:[NearChatNode class]])
    {
        NearChatNode *nearmsg = obj;
        NSString *sql = [NSString stringWithFormat:@"delete from chatHis  where msgFromUid='%@' or msgToUid='%@';DELETE from chatNearHis where myid='%@' or other='%@';",nearmsg.vo_id,nearmsg.vo_id,nearmsg.vo_id,nearmsg.vo_id];
        [g_data.sqlite NSSendSql:sql];
        
        [self notiRefreshMyMsg];
    }
}



posted @ 2012-12-06 13:35  废弃账号  阅读(140)  评论(0编辑  收藏  举报