0
“始终未能从‘UIViewController的’投射到不相关类型的‘TableViewCell’”演员总是失败
我试图操纵网点我TableViewCell控制器我得到这个错误。所以我想将一些数据从UIViewController转换为UITableViewCell。
“始终未能从‘UIViewController的’投射到不相关类型的‘TableViewCell’”演员总是失败
我试图操纵网点我TableViewCell控制器我得到这个错误。所以我想将一些数据从UIViewController转换为UITableViewCell。
-[UIStoryboardSegue destinationViewController]
返回UIViewController*
。假设TableViewCell
是UITableViewCell
的一个子类,演员阵容没有意义。从我看到的信息中,您需要检查destinationViewController
是否指向UITableViewController
的实例,然后进行投射。
UIViewController *viewController = [segue destinationViewController];
if ([viewController isKindOfClass:[UITableViewControler class]])
{
UITableViewController *tableViewController = (UITableViewController *) viewController;
}
从那里,你可以访问使用任何UITableViewController
的方法的细胞,可能是那些实现UITableViewDelegate
或UITableViewDataSource
。如果您需要更多实施特定控制,则在检查destinationViewController
是该类的一个实例后,您可以投射到TableVC
。
你可以在哪里得到错误代码? – Paulw11
@ Paulw11你碰巧检查附加的图像? –
不,我没有注意到,但是您应该始终在您的问题中包含相关代码,而不是将其包含在图像中 – Paulw11