当我打电话给这一行时:
((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
答案 0 :(得分:1)
iOS 5.0中引入了dismissViewControllerAnimated:completion:
选择器 - 您是否在较早的iOS版本上运行?
<强>更新强>
我刚尝试运行此代码:
var picker = new UIImagePickerController ();
picker.DismissViewController (true, () => Console.WriteLine ("foo!"));
它在我的机器上运行得很好,这意味着您显示的代码不足以重现您所看到的问题 - 所以也许您可以展示您的创建和使用方式图像选择器?
答案 1 :(得分:0)
使用DismissViewController完成处理程序是可行的方法
picker.DismissViewController (true,() => {
var labelPicsViewController = new LabelPicsViewController();
PresentViewController(labelPicsViewController,true,null);
});