我有一个Xamarin iOS应用程序,它运行正常,但我不知道我触摸了什么,所以当我点击按钮移动到故事板中的另一个视图时它开始引发此异常:
System.Exception: Failed to marshal the Objective-C object 0x7ffa72c19570 (type: PropertyListViewController). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'Rental.iOS.PropertyListViewController' does not have a constructor that takes one IntPtr argument).
at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSendSuper_bool_bool (intptr,intptr,bool,bool)
at UIKit.UIViewController.BeginAppearanceTransition (System.Boolean isAppearing, System.Boolean animated) [0x0002c] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/build/ios/native/UIKit/UIViewController.g.cs:168
at XLPagerTabStrip.PagerTabStripViewController.UpdateContent () [0x001c3] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:271
at XLPagerTabStrip.PagerTabStripViewController.Scrolled (UIKit.UIScrollView scrollView) [0x0000e] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:339
at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend_CGPoint (intptr,intptr,CoreGraphics.CGPoint)
at UIKit.UIScrollView.set_ContentOffset (CoreGraphics.CGPoint value) [0x00010] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/build/ios/native/UIKit/UIScrollView.g.cs:387
at XLPagerTabStrip.PagerTabStripViewController.UpdateContent () [0x00068] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:247
at XLPagerTabStrip.PagerTabStripViewController.Scrolled (UIKit.UIScrollView scrollView) [0x0000e] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:339
at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at Rental.iOS.Application.Main (System.String[] args) [0x00008] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/Main.cs:17
我可以在界面设计器中检查什么以确保我没有做错任何事情?
我添加了这个构造函数:
public partial class PropertyListViewController : UIViewController
{
protected PropertyListViewController(IntPtr handle) : base(handle)
{
// Note: this .ctor should not contain any initialization logic.
}
~~~~
}
但现在我收到了这个错误:
Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: -[UIViewController _loadViewFromNibNamed:bundle:] loaded the "PropertyListViewController" nib but the view outlet was not set.
Native stack trace:
0 CoreFoundation 0x000000010c73ad4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000011713a21e objc_exception_throw + 48
2 CoreFoundation 0x000000010c7a42b5 +[NSException raise:format:] + 197
3 UIKit 0x00000001101b6aea -[UIViewController _loadViewFromNibNamed:bundle:] + 679
4 UIKit 0x00000001101b72e7 -[UIViewController loadView] + 177
5 UIKit 0x00000001101b761c -[UIViewController loadViewIfRequired] + 201
6 UIKit 0x00000001101be062 -[UIViewController __viewWillAppear:] + 118
7 Rental.iOS 0x000000010c0c6f9c xamarin_dyn_objc_msgSendSuper + 220
8 ??? 0x0000000130fb7405 0x0 + 5116752901
at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSendSuper_bool_bool (intptr,intptr,bool,bool)
at UIKit.UIViewController.BeginAppearanceTransition (System.Boolean isAppearing, System.Boolean animated) [0x0002c] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/build/ios/native/UIKit/UIViewController.g.cs:168
at XLPagerTabStrip.PagerTabStripViewController.UpdateContent () [0x001c3] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:271
at XLPagerTabStrip.PagerTabStripViewController.Scrolled (UIKit.UIScrollView scrollView) [0x0000e] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:339
at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend_CGPoint (intptr,intptr,CoreGraphics.CGPoint)
at UIKit.UIScrollView.set_ContentOffset (CoreGraphics.CGPoint value) [0x00010] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/build/ios/native/UIKit/UIScrollView.g.cs:387
at XLPagerTabStrip.PagerTabStripViewController.UpdateContent () [0x00068] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:247
at XLPagerTabStrip.PagerTabStripViewController.Scrolled (UIKit.UIScrollView scrollView) [0x0000e] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/XLPagerTabStrip/PagerTabStripViewController.cs:339
at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at Rental.iOS.Application.Main (System.String[] args) [0x00008] in /Users/abd/Programming/Gits/Rental/Rental/Rental/Rental.iOS/Main.cs:17
答案 0 :(得分:4)
PropertyListViewController does not have a constructor that takes one IntPtr argument
。
在UIViewController
子类中,添加.ctor
,如下所示:
public partial class PropertyListViewController : UIViewController
{
protected PropertyListViewController(IntPtr handle) : base(handle)
{
// Note: this .ctor should not contain any initialization logic.
}
~~~~
}