Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin Studio上iOS Designer中感叹号的含义_Ios_Xamarin_Xamarin Studio - Fatal编程技术网

Xamarin Studio上iOS Designer中感叹号的含义

Xamarin Studio上iOS Designer中感叹号的含义,ios,xamarin,xamarin-studio,Ios,Xamarin,Xamarin Studio,我正在与iOS设计师合作,我有一个故事板,上面有不同的视图(导航控制器,…)。几乎每个视图的底部右侧都有一个红色感叹号。我会犯这样的错误 System.NullReferenceException 对象引用未设置为对象的实例 如果我转到相应的代码行: public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations () { return TopViewController.GetSupportedI

我正在与iOS设计师合作,我有一个故事板,上面有不同的视图(导航控制器,…)。几乎每个视图的底部右侧都有一个红色感叹号。我会犯这样的错误

System.NullReferenceException
对象引用未设置为对象的实例

如果我转到相应的代码行:

public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations ()
{
    return TopViewController.GetSupportedInterfaceOrientations();
}
这是我的
CustomNavigationController
的一部分。如果在iOS设计器上设置类名,则会出现错误。我必须在这里补充什么?构造函数如下所示:

public CustomNavigationController (IntPtr handle) : base (handle)
{
}
我必须在AppDelegate中实例化它吗

在另一个视图控制器上,我得到一个类似的异常(具有不同的堆栈),它将我指向这一行:

this.NavigationController.NavigationBar.TintColor = UIColor.FromRGB (21, 66, 139);
该应用程序似乎在模拟器和设备上运行良好

我如何解决这个问题

编辑:

我现在删除了视图控制器中的代码:

this.NavigationController.NavigationBar.TintColor = UIColor.FromRGB (21, 66, 139);
作为替换,我将此代码移动到应用程序委托
FinishedLaunching()

结果是,现在我没有这个视图控制器的感叹号,颜色符合要求。但是iOS设计器中的预览不再显示正确的颜色


如果我在my
CustomNavigationController
中注释掉
GetSupportedInterfaceOrientions()
,则会删除另一个感叹号。我想我需要这个函数来定义每个视图控制器的方向。快速查看表明它似乎有效。

设计时间支持的内容受到限制。在设计模式下,应使用虚拟数据替换任何动态数据,例如从服务加载的数据。这同样适用于运行时对象,如仅在运行时可用的
TopViewController

if (Site != null && Site.DesignMode)
{
    // use dummy data for designer surface
}
else
{
    // use live data
}
本文件对此进行了更详细的解释:


谢谢你提供我不知道的信息。所以我应该在设计模式下添加一个默认方向?这对访问
this.NavigationController
也有效吗?我不知道为什么我不能访问导航控制器。在iOS设计器中,此视图中缺少导航栏。现在我尝试使用此方法,但在iOS设计器中仍然得到
System.NullReferenceException
。。。下面是代码
if(Site!=null&&Site.DesignMode){return UIInterfaceOrientationMask.肖像;}或者{return TopViewController.GetSupportedInterfaceOrientations();}
I再次使用字符串进行了尝试。我得到了
UIViewControllerHierarchyInconsistency
。这种方法行不通。
if (Site != null && Site.DesignMode)
{
    // use dummy data for designer surface
}
else
{
    // use live data
}