views:

553

answers:

3

how can i get a uitableViewCell by indexPath? like this:

i use the UIActionSheet when i click confirm button i wan to change the cell text

the nowIndex i defin as a property

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
 if (buttonIndex == 0){
  NSInteger section =  [nowIndex section];
  NSInteger row = [nowIndex row];
  NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
  formatter.dateFormat = @"yyyy-MM-dd";
  if (section == 0){
   if (row == 0){

   }else if (row == 1){
    UILabel *content = (UILabel *)[[(UITableView *)[actionSheet ] cellForRowAtIndexPath:nowIndex] viewWithTag:contentTag];
    content.text = [formatter stringFromDate:checkInDate.date];
   }else if (row == 2){

   }
  }
 }
}
A: 

I'm not quite sure what your problem is, but you need to specify the parameter name like so.

-(void) changeCellText:(NSIndexPath *) nowIndex{
    UILabel *content = (UILabel *)[[(UITableViewCell *)[(UITableView *)self cellForRowAtIndexPath:nowIndex] contentView] viewWithTag:contentTag];
    content.text = [formatter stringFromDate:checkInDate.date];
}
David Kanarek
hi davidi rewrite the question ,can you see it again
phpxiaoxin
+1  A: 
[(UITableViewCell *)[(UITableView *)self cellForRowAtIndexPath:nowIndex]

will give you uitableviewcell. But I am not sure what exactly you are asking for! Because you have this code and still you asking how to get uitableviewcell. Some more information will help to answer you :)

Manjunath
A: 

finaly i get the cell use the fllowing code :

UITableViewCell *cell = (UITableViewCell *)[(UITableView *)self.view cellForRowAtIndexPath:nowIndex];

because the class is extend uitableviewController:

@interface SearchHotelView : UITableViewController

so self is "SearchHotelView",

i learn more throw this question,

thanks Manjunath and David Kanarek :)

phpxiaoxin