0

当按下 tableview 单元格时,使用 tableview 并尝试打开具有故事板和导航控制器的根视图控制器的 collectionviewcontroller 。但收到错误消息

应用程序试图在目标上推送一个 nil 视图控制器

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *viewController;
switch (indexPath.row) {
    case PDF: 
        viewController = [[[PDFExampleViewController alloc] init]autorelease];

        break;
    case IMAGE: 
//Rootviewcontroller of the navigation controller have no identifier. showDetail is the segue of the rootviewcontroller.

 viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"showDetail"];
        break;
    case PROCEDURAL:
        viewController = [[[ProceduralExampleViewController alloc] init] autorelease]; 
        break;
    default: 
        viewController = [[[UIViewController alloc] init] autorelease];
} 


[self.navigationController pushViewController:viewController animated:YES];
}

感谢帮助。


我不确定这里发生了什么,但要尝试调试它,我只会d.trainingDates从您的数据库查询返回而不是执行DateDiff,然后执行此操作来验证它:

If dr1.Read() Then
    Dim trngDate As Date = dr1("trainingDates")
    Response.Write(trngDate.ToString)
    If (trngDate - DateTime.Now).TotalDays >= 2 Then
        Return True
    Else
        Return False
    End If

End If

编辑

但是 - 为什么不只比较 RowDataBound 事件中的日期。

无需执行另一个查询,您要比较的日期在您绑定的行中

像这样(未经测试)的代码:

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    If e.Row.RowType = DataControlRowType.DataRow Then
        Dim dateValue As Date = Date.Parse(Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Dates")))
        Dim btn As Button = DirectCast(e.Row.FindControl("cancelBtn"), Button)
        btn.Enabled = (dateValue - DateTime.Now).TotalDays >= 2
    End If
End Sub
4

0 回答 0