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