2017-02-21 10 views
2

У меня есть приложение 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 

Что я могу проверить в Designer Interface, чтобы убедиться, что я не делаю ничего плохого?

Я добавил thhis конструктор:

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 

ответ

2

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. 
    } 
    ~~~~ 
} 
+0

Спасибо, я проверю, но я не имел этого конструктора раньше, и он работает должным образом! – AVEbrahimi

+0

@AVEbrahimi Если вы используете этот 'UIViewController' через раскадровку/xib, это необходимо. Если вы создаете его в коде, он не нужен ... – SushiHangover

+0

Я добавил конструктор, о котором вы упомянули, но теперь я получаю эту ошибку: – AVEbrahimi

Смежные вопросы