0
我是新来的目标c,并试图找出uitableview。我添加了两个单元格到tableview,当我点击tableview的任何区域,两个单元格消失或标签被删除。我不确定。我怎样才能解决这个问题?目标c点击tableview时,单元格消失
这里是我如何添加两个单元
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if(indexPath.row==0)
[email protected]"test 1";
else if (indexPath.row==1)
[email protected]"test 2";
// Configure the cell...
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
我已经给出了部分和行
粘贴代表以及数据源方法您的完整代码.. – user968597 2013-05-10 13:11:39
没有数据源或代表。我是新来的目标C :) – 2013-05-10 13:12:27
首先你需要设置你的表中的行数,然后你可以定义单元格cellForAtIndexPath – user968597 2013-05-10 13:14:09