本文整理汇总了C#中UIImagePickerController.DismissModalViewControllerAnimated方法的典型用法代码示例。如果您正苦于以下问题:C# UIImagePickerController.DismissModalViewControllerAnimated方法的具体用法?C# UIImagePickerController.DismissModalViewControllerAnimated怎么用?C# UIImagePickerController.DismissModalViewControllerAnimated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIImagePickerController
的用法示例。
在下文中一共展示了UIImagePickerController.DismissModalViewControllerAnimated方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FinishedPickingMedia
public override void FinishedPickingMedia (UIImagePickerController picker, NSDictionary info)
{
var cb = _callback;
_callback = null;
picker.DismissModalViewControllerAnimated (true);
cb (info);
}
示例2: Canceled
public override void Canceled (UIImagePickerController picker)
{
var cb = _oncancel;
_oncancel = null;
_callbackImg = null;
picker.DismissModalViewControllerAnimated(true);
cb();
}
示例3: FinishedPickingImage
public override void FinishedPickingImage (UIImagePickerController picker, UIImage image, NSDictionary editingInfo)
{
var cb = _callbackImg;
_oncancel = null;
_callbackImg = null;
picker.DismissModalViewControllerAnimated(true);
cb(image);
}
示例4: FinishedPickingMedia
public override void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
{
UIImage image = (UIImage)info.ObjectForKey(new NSString("UIImagePickerControllerOriginalImage"));
// do whatever else you'd like to with the image
Console.WriteLine("media {0} x {1}", image.CGImage.Width, image.CGImage.Height);
picker.DismissModalViewControllerAnimated(true);
_imageView.Image = image;
if (_popover != null && _popover.PopoverVisible)
_popover.Dismiss(true);
}
示例5: ShowImage
private void ShowImage(UIImage image, UIImagePickerController picker)
{
if (this.HasHighResScreen())
image = image.Scale(new SizeF(new PointF(640, 640)));
_controller.imageView.Image = image;
picker.DismissModalViewControllerAnimated(true);
}
示例6: FinishedPickingImage
public override void FinishedPickingImage (UIImagePickerController picker, UIImage image, NSDictionary editingInfo)
{
if (picker.SourceType == UIImagePickerControllerSourceType.Camera)
{
image.SaveToPhotosAlbum(delegate(UIImage savedImage, NSError error) {
_controller.SaveImage(savedImage);
});
}
else
{
_controller.SaveImage(image);
}
picker.DismissModalViewControllerAnimated(true);
}
示例7: ShowImagePicker
private void ShowImagePicker()
{
imagePicker = new UIImagePickerController ();
imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);
imagePicker.FinishedPickingMedia += (sender, e) => {
bool isImage = (e.Info [UIImagePickerController.MediaType].ToString () == "public.image");
NSUrl referenceUrl = e.Info [UIImagePickerController.ReferenceUrl] as NSUrl;
UIImage image = null;
NSUrl mediaUrl = null;
if (isImage) {
image = e.Info [UIImagePickerController.OriginalImage] as UIImage;
} else {
mediaUrl = e.Info [UIImagePickerController.MediaURL] as NSUrl;
}
UploadMedia (image, referenceUrl, mediaUrl);
imagePicker.DismissModalViewControllerAnimated (true);
};
imagePicker.Canceled += (sender, e) => {
imagePicker.DismissModalViewControllerAnimated (true);
};
navigation.PresentModalViewController (imagePicker, true);
}
示例8: FinishedPickingMedia
public override void FinishedPickingMedia (UIImagePickerController picker, NSDictionary info)
{
// determine what was selected, video or image
bool isImage = false;
switch (info [UIImagePickerController.MediaType].ToString ()) {
case "public.image":
Console.WriteLine ("Image selected");
isImage = true;
break;
Console.WriteLine ("Video selected");
case "public.video":
break;
}
//MT BUGBUG:
Console.Write ("Reference URL: [" + UIImagePickerController.ReferenceUrl + "]");
// // get common info (shared between images and video)
// NSUrl referenceURL = info[new NSString("UIImagePickerControllerReferenceUrl")] as NSUrl;
// if(referenceURL != null)
// {
// //
// Console.WriteLine(referenceURL.ToString());
// }
// if it was an image, get the other image info
if (isImage) {
// // get the original image
// UIImage originalImage = info[UIImagePickerController.OriginalImage] as UIImage;
// if(originalImage != null)
// {
// // do something with the image
// Console.WriteLine("got the original image");
// }
// // get the edited image
// UIImage editedImage = info[UIImagePickerController.EditedImage] as UIImage;
// if(editedImage != null)
// {
// // do something with the image
// Console.WriteLine("got the edited image");
//
//
// }
// // get the cropping, if any
// try
// {
// RectangleF cropRectangle = (RectangleF)info[UIImagePickerController.CropRect];
// if(cropRectangle != null)
// {
// // do something with the crop rectangle
// Console.WriteLine("Got the crop rectangle");
// }
// } finally {}
// //- get the image metadata
// NSDictionary imageMetadata = info[UIImagePickerController.MediaMetadata] as NSDictionary;
// if(imageMetadata != null)
// {
// // do something with the metadata
// Console.WriteLine("got image metadata");
// }
}
// dismiss the picker
picker.DismissModalViewControllerAnimated (true);
}
示例9: Canceled
public override void Canceled (UIImagePickerController picker)
{
Console.WriteLine ("picker cancelled");
picker.DismissModalViewControllerAnimated (true);
}
示例10: FinishedPickingMedia
public override void FinishedPickingMedia (UIImagePickerController picker, NSDictionary info)
{
picker.DismissModalViewControllerAnimated (true);
string mediaType = info[new NSString ("UIImagePickerControllerMediaType")].ToString ();
UIImage img = null;
if (mediaType == "public.image") {
img = (UIImage)info[new NSString ("UIImagePickerControllerOriginalImage")];
_controller.playMovie.Hidden = true;
} else if (mediaType == "public.movie") {
NSUrl videoUrl = (NSUrl)info[new NSString ("UIImagePickerControllerMediaURL")];
_controller._mp = new MPMoviePlayerController (videoUrl);
img = _controller._mp.ThumbnailImageAt (0, MPMovieTimeOption.NearestKeyFrame);
_controller.playMovie.Hidden = false;
}
if (img != null)
_controller.imageView.Image = img;
}
示例11: GetPicture
public void GetPicture(CameraOptions options, Action<string> successCallback, Action errorCallback)
{
if(options == null)
options = new CameraOptions();
if(!UIImagePickerController.IsSourceTypeAvailable(options.SourceType))
{
Debug.WriteLine ("Source type {0} isn't available.", options.SourceType);
return;
}
pickerController = new UIImagePickerController();
pickerController.AllowsEditing = options.AllowEdit;
pickerController.SourceType = options.SourceType;
pickerController.FinishedPickingMedia += delegate(object sender, UIImagePickerMediaPickedEventArgs e) {
pickerController.DismissModalViewControllerAnimated(true);
float quality = options.Quality / 100.0f;
var mediaType = (NSString) e.Info[new NSString("UIImagePickerControllerMediaType")];
if(mediaType == "public.image")
{
// Get the image
UIImage image = null;
if(pickerController.AllowsEditing && e.Info[new NSString("UIImagePickerControllerEditedImage")] != null)
image = (UIImage) e.Info[new NSString("UIImagePickerControllerEditedImage")];
else
image = (UIImage) e.Info[new NSString("UIImagePickerControllerOriginalImage")];
var data = image.AsJPEG(quality);
if(options.Destination == DestinationType.FileUri)
{
var basedir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "..");
var tmpDirectory = Path.Combine(basedir, "tmp");
if (!Directory.Exists(tmpDirectory))
Directory.CreateDirectory(tmpDirectory);
string filePath;
int i = 1;
do {
filePath = String.Format("{0}/photo_{1}.jpg", tmpDirectory, i++);
}
while (File.Exists(filePath));
NSError error = null;
if(!data.Save(filePath, false, out error))
{
Debug.WriteLine ("Error {0}", error.LocalizedDescription);
errorCallback();
}
else
successCallback(filePath);
}
else
{
var bytearray = new Byte[data.Length];
Marshal.Copy(data.Bytes, bytearray, 0, Convert.ToInt32(data.Length));
successCallback(Convert.ToBase64String(bytearray));
}
}
};
pickerController.Canceled += delegate(object sender, EventArgs e) {
pickerController.DismissModalViewControllerAnimated(true);
errorCallback();
};
viewController.PresentModalViewController(pickerController, true);
}
示例12: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
Title = "Image Picker";
// populate the features table
PopulateFeaturesTable ();
btnChoosePhoto.TouchUpInside += (s, e) => {
// create a new picker controller
imagePicker = new UIImagePickerController ();
// set our source to the photo library
imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
// set what media types
imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);
// As with most controls, you can either handle the events directly, or
// wire up a delegate. in this first one, i wire up the events. in the other two,
// i use a delegate
imagePicker.FinishedPickingMedia += Handle_imagePickerhandleFinishedPickingMedia;
imagePicker.Canceled += (sender,evt) => {
Console.WriteLine ("picker cancelled");
imagePicker.DismissModalViewControllerAnimated (true);
};
// show the picker
NavigationController.PresentModalViewController (imagePicker, true);
};
btnTakePhoto.TouchUpInside += (s, e) => {
try {
// create a new picker controller
imagePicker = new UIImagePickerController ();
// set our source to the camera
imagePicker.SourceType = UIImagePickerControllerSourceType.Camera;
// set what media types
imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.Camera);
// show the camera controls
imagePicker.ShowsCameraControls = true;
// attach the delegate
pickerDelegate = new ImagePickerScreen.PickerDelegate ();
imagePicker.Delegate = pickerDelegate;
// show the picker
NavigationController.PresentModalViewController (imagePicker, true);
} catch (Exception ex) {
UIAlertView alert = new UIAlertView ("No Camera", "No Camera Detected!", null, "OK", null);
alert.Show ();
}
};
btnPhotoRoll.TouchUpInside += (s, e) => {
// create a new picker controller
imagePicker = new UIImagePickerController ();
// set our source to the camera
imagePicker.SourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum;
// set what media types
imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.SavedPhotosAlbum);
// attach the delegate
pickerDelegate = new ImagePickerScreen.PickerDelegate ();
imagePicker.Delegate = pickerDelegate;
// show the picker
NavigationController.PresentModalViewController (imagePicker, true);
};
}