views:

51

answers:

3

Hi,

Is there any way to change the cell.detailTextLabel from the app? For example, the user have to choose gender, I would like to display the selected gender under the detailTextLabel

Thanks!

A: 

EDIT:

You shouldn't access cell.detailTextLabel directly in the code of another class. What you should do is to have an array of properties to set.

You can set the like [myMutableArray replaceObjectAtIndex:myIndex withObject:@"USER_SELECT"];

then you call

[self.tableView reloadData];

and inside the method

- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   cell.detailTextLabel.text = [myMutableArray objectAtIndex:indexPath.row];
}
vodkhang
Thanks, I want the user to set it...
Guy Dor
Yeah, then you can just set it to some NSString variable, what's wrong there?
vodkhang
+2  A: 

You have access to all the properties of cell.detailTextLabel in code.

Note: You probably want to do all this in cellForRowAtIndexPath:.

jv42
Yes, you're right. I also tried to access the cell from another class but it didn't update the detailTextLabel
Guy Dor
+2  A: 

is user changing gender inside the table ?? then I believe you have to reload the table.. and in the cellForRowAtIndex method...

show the label for the desired row... do this in if condition... as if user has selected gender it will show selected else it will show choose gender...

KiranThorat