0

I m trying to create a camera Custom UI (somewhat like Instagram camera view )

Can Some one help me with adding .xib (layout for my cameraOverlayView) as cameraOverlayView .

inside -> ViewDidLoad()

        base.ViewDidLoad();
        var imagePickerControl = new UIImagePickerController();
        imagePickerControl.SourceType =  UIImagePickerControllerSourceType.Camera;
        imagePickerControl.ShowsCameraControls = true;
        //Code lines needed to add the xib "CameraOverlayView.xib" as uiview to pass next line  
        imagePickerControl.CameraOverlayView = ;

        var imagePickerDelegate = new CameraImagePicker(this);
        imagePickerControl.Delegate = imagePickerDelegate;
        NavigationController.PresentModalViewController(imagePickerControl, true);

I was refering to https://developer.xamarin.com/recipes/ios/general/templates/using_the_ios_view_xib_template/

But I was unable to add the xib as my CameraOverlay

Ask for related code if needed .. thanks in advance

samridhgupta
  • 1,695
  • 1
  • 18
  • 34
  • Did you add the `Create` method described in that tutorial? You need to inflate the xib into a `UIView` and that is your `CameraOverlayView`. The tutorial explains how to inflate the xib using a static `Create` method. – dylansturg Aug 23 '16 at 15:34
  • So according to you what approach should follow to add this xib as my CameraOverlay and even handle my Camera buttons (take picture and cancel ) which are on XIB layout. – samridhgupta Aug 23 '16 at 16:27
  • Remember that a XIB creates a `UIView` - that's what they do. A XIB exists purely to be inflated into a `UIView` (or a subclass of `UIView`). (When you load a `UIViewController` from XIB, it's basically loading that XIB as the `View`). If there are buttons in your XIB, then you need to connect those to outlets in your XIB's code behind. You need to use the XIB's code behind (that C# file). Once the buttons are exposed as properties, you can assign events or do whatever you want from code. – dylansturg Aug 23 '16 at 16:35
  • Is there any syntax so that i can directly pass this xib UIview to "imagePickerControl.CameraOverlayView = ;" some working code snippet for this would be very useful . – samridhgupta Aug 23 '16 at 16:53
  • Use the `Create` method from the article you linked... `imagePickerControl.CameraOverlayView = MyFancyXib.Create()`. – dylansturg Aug 23 '16 at 17:05
  • In CameraOverlayView.cs (the UIView class ):: `>>var arr = NSBundle.MainBundle.LoadNib("CameraOverlayView", null, null); >>var v = Runtime.GetNSObject(arr.ValueAt(0));` in these lines error that Runtime is not present in present context when I fix it adding `using Mono` there is another error: 'Runtime' doesnot contain 'GetNSObject'. how can i overcome this roadbloack. thanks in advance [>> is for nxt line code] – samridhgupta Aug 23 '16 at 17:21
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/121656/discussion-between-samridhgupta-and-dylansturg). – samridhgupta Aug 23 '16 at 18:00
  • Chat is blocked for me. Sorry. Simply use `using ObjCRuntime;` instead of `using Mono;`. – dylansturg Aug 23 '16 at 18:11
  • Thanks a lot , now i m able to view the overlay , but still unable to handle the button clicks.. – samridhgupta Aug 24 '16 at 10:02
  • Did you add outlets for your buttons? Are you adding an event handler to their `TouchUpInside` event? – dylansturg Aug 24 '16 at 12:37

0 Answers0