2012-02-28 6 views
0

im с использованием данных ядра У меня есть объект, называемый вопросами всякий раз, когда я добавляю свой вопрос в свою таблицу, я хочу, чтобы они отображали номер вопроса (вроде как функция автоматического приращения) can кто-нибудь пожалуйста, помогите мне спасибоЯ хочу, чтобы номера моих строк в UITableView

вот мой код, если его соответствующим

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 

// Return the number of sections. 
return 1; 
    } 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 

    // Return the number of rows in the section. 
    return [self.questionArray count]; 
    } 

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


UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 


// Configure the cell... 

questionObject = [self.questionArray objectAtIndex:indexPath.row]; 

cell.textLabel.text = questionObject.questionDescription; 


return cell; 
} 

ответ

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


    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 
    if (nil == cell) { 
     cell = ...; //create a cell instance if it wasn't found in reusable cache 
    } 

    // Configure the cell... 

    questionObject = [self.questionArray objectAtIndex:indexPath.row]; 

    NSString *cellText = [NSString stringWithFormat:@"%d. %@", indexPath.row+1, questionObject.questionDescription]; 
    cell.textLabel.text = cellText; 


    return cell; 
} 
+0

спасибо много он работал !!!! – newstar7867