【问题标题】:Table Views Pushing to New Views XIB's表视图推送到新视图 XIB 的
【发布时间】:2011-03-18 10:46:47
【问题描述】:

我创建了一个表格视图,它从数组中提取其单元格。

每个单元格都需要推送到不同的视图...我找不到被点击的单元格的值。它需要一个条件语句,但没有值我无法推送视图:(

下面是我的 didSelectRowAtIndexPath 的 sn-p

- (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 语句是空白的...我需要将列的值推送到另一个视图控制器。

请帮忙!谢谢

【问题讨论】:

    标签: iphone cocoa-touch ios object ios4


    【解决方案1】:

    我会为那些可能正在寻找它的人回答我自己的问题,因为我刚刚解决了:)

    使用:

    if([InsertYourArrayOfDataHere objectAtIndex:indexPath.row] == @"StringInArray")
    

    希望对遇到同样问题的人有所帮助

    【讨论】:

      【解决方案2】:

      即使在乔纳森的回答之后我还是建议使用这个,最好使用

      if([[InsertYourArrayOfDataHere objectAtIndex:indexPath.row] isEqualToString: @"StringInArray"]) {
      //Your Code goes here.
      }
      

      如果你在比较字符串,你应该使用 isEqualToString 方法。

      【讨论】:

        【解决方案3】:
        - (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];
        }
        

        【讨论】:

          【解决方案4】:

          你可以找到点击单元格的值

          indexpath.row,

          当用户触摸任何单元格值时,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
          
          }
          

          希望这能解决您的问题。

          【讨论】:

          • 谢谢。我刚刚解决了:) 在你的帖子之后几秒钟看到帖子!还是谢谢!
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-07-20
          • 1970-01-01
          • 1970-01-01
          • 2016-08-31
          相关资源
          最近更新 更多