1

当我调用此行时:

((UIImagePickerController)sender).DismissViewController (true, () => {});

我得到这个错误。请帮忙

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[UIImagePickerController dismissViewControllerAnimated:completion:]: unrecognized selector sent to instance 0xb647ed0
    at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend_bool_IntPtr (intptr,intptr,bool,intptr)
    at MonoTouch.UIKit.UIViewController.DismissViewController (Boolean animated, MonoTouch.Foundation.NSAction completionHandler) [0x00036] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIViewController.g.cs:678
    at ECPIInstructorObservationForm.Section1.Handle_FinishedPickingMedia (System.Object sender, MonoTouch.UIKit.UIImagePickerMediaPickedEventArgs e) [0x00142] in /Users/kjohnson/Projects/ECPIInstructorObservationForm/ECPIInstructorObservationForm/Section1.cs:298
    at MonoTouch.UIKit.UIImagePickerController+_UIImagePickerControllerDelegate.FinishedPickingMedia (MonoTouch.UIKit.UIImagePickerController picker, MonoTouch.Foundation.NSDictionary info) [0x00014] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIImagePickerController.g.cs:601
    at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
    at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
    at ECPIInstructorObservationForm.Application.Main (System.String[] args) [0x00000] in /Users/kjohnson/Projects/ECPIInstructorObservationForm/ECPIInstructorObservationForm/Main.cs:17
4

2 回答 2

1

选择dismissViewControllerAnimated:completion:器是在 iOS 5.0 中引入的 - 您是否在早期的 iO​​S 版本上运行?

更新

我刚刚尝试运行此代码:

var picker = new UIImagePickerController ();
picker.DismissViewController (true, () => Console.WriteLine ("foo!"));

它在我的机器上运行得很好,这意味着您显示的代码不足以重现您看到的问题 - 所以也许您可以展示您如何创建和使用图像选择器?

于 2012-10-26T10:46:53.087 回答
0

使用 DismissViewController 完成处理程序是要走的路

picker.DismissViewController (true,() => {
    var labelPicsViewController = new LabelPicsViewController();
    PresentViewController(labelPicsViewController,true,null);
});
于 2014-09-04T14:08:14.337 回答