Iphone 表视图推送到新视图XIB
我创建了一个表视图,它从数组中提取单元格 每个单元格需要推送到不同的视图。。。而且我找不到被抽头的单元格的值。它需要一个条件语句,但如果没有该值,我无法推送视图: 下面是我的didSelectRowAtIndexPath的片段Iphone 表视图推送到新视图XIB,iphone,cocoa-touch,ios,object,ios4,Iphone,Cocoa Touch,Ios,Object,Ios4,我创建了一个表视图,它从数组中提取单元格 每个单元格需要推送到不同的视图。。。而且我找不到被抽头的单元格的值。它需要一个条件语句,但如果没有该值,我无法推送视图: 下面是我的didSelectRowAtIndexPath的片段 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic may go here. Create an
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
if(){
SendSms *detailViewController = [[SendSms alloc] initWithNibName:@"SendSms" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
}
您将看到If语句为空。。。我需要push列的值以推送到另一个视图控制器
请帮忙!谢谢您可以找到抽头单元格的值,如 行 当用户触摸任何单元格值时,indexpath.row将为您提供一个数字,然后您可以执行以下操作
if(indexpath.row == 0)
{
//here create the object for the view1 where you want to navigate
//show view 1
}
else
{
//show view 2
}
希望这能解决您的问题。我将回答我自己的问题,供那些可能正在搜索的人参考,因为我刚刚解决了这个问题: 使用:
希望这可能会帮助有同样问题的人即使在Jonathan的回答之后,我建议使用这个,但最好使用
if([[InsertYourArrayOfDataHere objectAtIndex:indexPath.row] isEqualToString: @"StringInArray"]) {
//Your Code goes here.
}
如果要比较字符串,应使用isEqualToString方法。谢谢。我刚算出:在你的帖子后面几秒钟再看帖子!无论如何谢谢你!
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//you willget alldetail of cell here.
if(){
SendSms *detailViewController = [[SendSms alloc] initWithNibName:@"SendSms" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//you willget alldetail of cell here.
if(){
SendSms *detailViewController = [[SendSms alloc] initWithNibName:@"SendSms" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}