简体   繁体   English

来自iPhone的表格视图单元格值

[英]Table View Cell value from iphone

I just want to get the value of a cell in the table view when i tap on it.. can any one help me in this.? 我只想在点击表格时在表格视图中获取一个单元格的值..任何人都可以帮我这个忙吗?

Thanks in Advance Shibin Moideen 在此先感谢Shibin Moideen

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    appDelegate.courseName=[appDelegate.courses objectAtIndex:indexPath];
    NSLog(@"%@",appDelegate.courseName);
    DetailCourseViewController *detailController = [[DetailCourseViewController alloc]
                                                       initWithNibName:@"DetailCourseView" bundle:nil];
    [self presentModalViewController:detailController animated:YES];
}

is that done in this way. 是以这种方式完成的。 also i need to store that value in a string which i declared in the app delegate. 我还需要将该值存储在我在应用程序委托中声明的字符串中。

You use the tableView:didSelectRowAtIndexPath: delegate method and use the indexPath to return the cell that was tapped. 您使用tableView:didSelectRowAtIndexPath:委托方法,并使用indexPath返回被点击的单元格。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSLog(@"%@", cell);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM