本文整理汇总了C#中UIPopoverController.PresentFromBarButtonItem方法的典型用法代码示例。如果您正苦于以下问题:C# UIPopoverController.PresentFromBarButtonItem方法的具体用法?C# UIPopoverController.PresentFromBarButtonItem怎么用?C# UIPopoverController.PresentFromBarButtonItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIPopoverController
的用法示例。
在下文中一共展示了UIPopoverController.PresentFromBarButtonItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShareUrl
public void ShareUrl(object sender, Uri uri)
{
var item = new NSUrl(uri.AbsoluteUri);
var activityItems = new NSObject[] { item };
UIActivity[] applicationActivities = null;
var activityController = new UIActivityViewController (activityItems, applicationActivities);
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
{
var window = UIApplication.SharedApplication.KeyWindow;
var pop = new UIPopoverController (activityController);
var barButtonItem = sender as UIBarButtonItem;
if (barButtonItem != null)
{
pop.PresentFromBarButtonItem(barButtonItem, UIPopoverArrowDirection.Any, true);
}
else
{
var rect = new CGRect(window.RootViewController.View.Frame.Width / 2, window.RootViewController.View.Frame.Height / 2, 0, 0);
pop.PresentFromRect (rect, window.RootViewController.View, UIPopoverArrowDirection.Any, true);
}
}
else
{
var viewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
viewController.PresentViewController(activityController, true, null);
}
}
示例2: ViewDidLoad
// moveToVerifyViewSegue
public override void ViewDidLoad()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
btnAdd.Enabled = false;
PopMenuView = new PopMenuViewController ();
PopMenuView.FeatureSelected += (sender, e) => {
Debug.WriteLine (e.SelectedFeatureName);
if ("Edit" == e.SelectedFeatureName) {
btnAdd.Enabled = true;
}
else if ("Edit" == e.SelectedFeatureName) {
btnAdd.Enabled = true;
}
else {
btnAdd.Enabled = false;
}
};
btnMenu.Clicked += (sender, e) => {
UIPopoverController pop = new UIPopoverController (PopMenuView);
pop.SetPopoverContentSize (new CGSize (200, 150), true);
pop.PresentFromBarButtonItem ( btnMenu, UIPopoverArrowDirection.Any, true);
};
btnAdd.Clicked += (sender, e) => {
PerformSegue ("moveToFlow01ViewSegue", this);
};
var editingVotes = new VoteManager ().ReadEditVotesFromRemote ();
AppDelegate.EditingVotes.AddRange (editingVotes);
var source = new TableSource (AppDelegate.EditingVotes);
editingVoteTable.Source = source;
source.EditingVoteSelected += ( sender, e) => {
AppDelegate.SelectedEditingVote = e.SelectedEditingVote;
if (AppDelegate.SelectedEditingVote.Status == EditStatus.Request) {
PerformSegue ("moveToVerifyViewSegue", this);
}
};
}
示例3: SharePlaceInfo
void SharePlaceInfo (object sender, EventArgs e)
{
var message = new NSString (string.Format("{0}\n{1}\n{2}", viewModel.Place.Name, viewModel.Place.Website, viewModel.ShortAddress));
var activityController = new UIActivityViewController (new NSObject [] {
message
}, null);
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) {
shareController = new UIPopoverController (activityController);
shareController.PresentFromBarButtonItem(shareButton, UIPopoverArrowDirection.Any, true);
} else {
PresentViewController(activityController, true, null);
}
}
示例4: ShowAlertViewController
void ShowAlertViewController (string showMapsButtonTitle, string makeCallButtonTitle, string addToContactsButtonTitle, string streetViewButtonTitle, string cancelButtonTitle)
{
var alertController = UIAlertController.Create(null, null, UIAlertControllerStyle.ActionSheet);
alertController.AddAction(UIAlertAction.Create(streetViewButtonTitle, UIAlertActionStyle.Default, OpenStreetView));
alertController.AddAction(UIAlertAction.Create(showMapsButtonTitle, UIAlertActionStyle.Default, ShowMaps));
alertController.AddAction(UIAlertAction.Create(makeCallButtonTitle, UIAlertActionStyle.Default, MakeACall));
alertController.AddAction(UIAlertAction.Create(addToContactsButtonTitle, UIAlertActionStyle.Default, AddContact));
alertController.AddAction(UIAlertAction.Create(cancelButtonTitle, UIAlertActionStyle.Destructive, null));
SetupPopover(alertController, View);
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) {
var moreController = new UIPopoverController (alertController);
moreController.PresentFromBarButtonItem(moreButton, UIPopoverArrowDirection.Any, true);
} else {
PresentViewController(alertController, true, null);
}
}
示例5: SendLoginAsync
private async Task<Auth0User> SendLoginAsync(
RectangleF rect,
object view,
string connection,
bool withRefreshToken,
string scope,
string title)
{
// Launch server side OAuth flow using the GET endpoint
scope = IncreaseScopeWithOfflineAccess(withRefreshToken, scope);
var tcs = new TaskCompletionSource<Auth0User> ();
var auth = await this.GetAuthenticator (connection, scope, title);
UIViewController c = auth.GetUI();
UIViewController controller = null;
UIPopoverController popover = null;
auth.Error += (o, e) =>
{
if (controller != null) {
controller.DismissViewController (true, null);
}
if (popover != null) {
popover.Dismiss (true);
}
var ex = e.Exception ?? new AuthException (e.Message);
tcs.TrySetException (ex);
};
auth.Completed += (o, e) =>
{
if (controller != null) {
controller.DismissViewController (true, null);
}
if (popover != null) {
popover.Dismiss (true);
}
if (!e.IsAuthenticated) {
tcs.TrySetCanceled();
}
else
{
this.SetupCurrentUser (e.Account.Properties);
tcs.TrySetResult (this.CurrentUser);
}
};
controller = view as UIViewController;
if (controller != null)
{
controller.PresentViewController (c, true, null);
}
else
{
UIView v = view as UIView;
UIBarButtonItem barButton = view as UIBarButtonItem;
popover = new UIPopoverController (c);
if (barButton != null) {
popover.PresentFromBarButtonItem (barButton, UIPopoverArrowDirection.Any, true);
}
else {
popover.PresentFromRect (rect, v, UIPopoverArrowDirection.Any, true);
}
}
return await tcs.Task;
}
示例6: settingsTouched
public virtual void settingsTouched(object sender, EventArgs e)
{
SettingsViewController settings = new SettingsViewController (this);
UIUserInterfaceIdiom idiom = UIDevice.CurrentDevice.UserInterfaceIdiom;
if (idiom == UIUserInterfaceIdiom.Pad)
{
if (popover != null && popover.PopoverVisible)
{
popover.Dismiss (true);
return;
}
popover = new UIPopoverController (settings);
CGRect settingsRect = settings.View.Bounds;
settings.Table.SizeToFit ();
popover.PopoverContentSize = new CGSize ((float)(Math.Min(settingsRect.Size.Width, settingsRect.Size.Height) / 2.0), settings.Table.ContentSize.Height);
popover.PresentFromBarButtonItem (settingsButton, UIPopoverArrowDirection.Up, true);
}
else
{
this.NavigationController.PushViewController (settings, true);
}
}
示例7: InvoiceViewController
public InvoiceViewController ()
{
SetTitle ();
Settings.Shared.SubscribeToProperty ("TestMode", SetTitle);
var searchBar = new ItemSearchView{ Frame = new System.Drawing.RectangleF (0, 0, 200, 30) };
searchBar.ItemSelected += (Item obj) => {
Invoice.AddItem (obj);
};
NavigationItem.RightBarButtonItem = new UIBarButtonItem (searchBar);
NavigationItem.LeftBarButtonItem = new UIBarButtonItem (UIImage.FromBundle ("menu").ImageWithRenderingMode (UIImageRenderingMode.AlwaysTemplate), UIBarButtonItemStyle.Plain, (s, e) => {
//Show simple actionsheet
if (sheet != null) {
sheet.DismissWithClickedButtonIndex (-1, true);
return;
}
sheet = new SimpleActionSheet {
{"New Invoice",async() =>{
if(await AskSave())
NewInvoice();
}
},
{"Load Invoice",() => {
if(popover != null)
{
popover.Dismiss(true);
}
popover = new UIPopoverController(new UINavigationController(new LoadInvoiceViewController(){
InvoiceSelected = async (i) =>{
popover.Dismiss(true);
try{
BigTed.BTProgressHUD.ShowContinuousProgress();
if(Invoice != null && Invoice.Id != i.Id)
{
if(!await AskSave())
return;
}
Invoice.DeleteLocal();
Invoice = await WebService.Main.GetInvoice(i.Id);
Invoice.Save(true);
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
finally{
BigTed.BTProgressHUD.Dismiss();
}
},
}));
popover.DidDismiss += (sender, evt) => {
popover.Dispose();
};
popover.PresentFromBarButtonItem(NavigationItem.LeftBarButtonItem, UIPopoverArrowDirection.Any,true);
}
},
{"Payout Buy",() => {
if(popover != null)
{
popover.Dismiss(true);
}
popover = new UIPopoverController(new UINavigationController(new LoadBuyPayoutViewController(){
InvoiceSelected = async (i) =>{
popover.Dismiss(true);
try{
BigTed.BTProgressHUD.ShowContinuousProgress();
if(Invoice != null && Invoice.Id != i.Id)
{
if(!await AskSave())
return;
}
Invoice.DeleteLocal();
Invoice = await WebService.Main.GetInvoice(i.Id);
//Setup payments
Database.Main.Table<PaymentType> ().Where (x => x.IsActive)
.OrderBy (X => X.SortOrder).ToList ().ForEach (x => Invoice.Payments.Add (new Payment{ PaymentType = x }));
Invoice.Save(true);
if((i as BuyInvoice).IsOnAccount)
Invoice.OnAccountPayment.Amount = Invoice.Total;
else
Invoice.CashPayment.Amount = Invoice.Total;
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
finally{
BigTed.BTProgressHUD.Dismiss();
}
},
}));
popover.DidDismiss += (sender, evt) => {
popover.Dispose();
};
popover.PresentFromBarButtonItem(NavigationItem.LeftBarButtonItem, UIPopoverArrowDirection.Any,true);
}
},
{"Settings",() => this.PresentViewControllerAsync (new UINavigationController (new SettingsViewController ()), true)},
};
sheet.Dismissed += (object sender, UIButtonEventArgs e2) => {
//.........这里部分代码省略.........
示例8: LoginAsyncOverride
protected override Task<string> LoginAsyncOverride()
{
var tcs = new TaskCompletionSource<string>();
var auth = new WebRedirectAuthenticator(StartUri, EndUri);
auth.ShowUIErrors = false;
auth.ClearCookiesBeforeLogin = false;
UIViewController c = auth.GetUI();
UIViewController controller = null;
UIPopoverController popover = null;
auth.Error += (o, e) =>
{
NSAction completed = () =>
{
Exception ex = e.Exception ?? new Exception(e.Message);
tcs.TrySetException(ex);
};
if (controller != null)
controller.DismissViewController(true, completed);
if (popover != null)
{
popover.Dismiss(true);
completed();
}
};
auth.Completed += (o, e) =>
{
NSAction completed = () =>
{
if (!e.IsAuthenticated)
tcs.TrySetException(new InvalidOperationException("Authentication was cancelled by the user."));
else
tcs.TrySetResult(e.Account.Properties["token"]);
};
if (controller != null)
controller.DismissViewController(true, completed);
if (popover != null)
{
popover.Dismiss(true);
completed();
}
};
controller = view as UIViewController;
if (controller != null)
{
controller.PresentViewController(c, true, null);
}
else
{
UIView v = view as UIView;
UIBarButtonItem barButton = view as UIBarButtonItem;
popover = new UIPopoverController(c);
if (barButton != null)
popover.PresentFromBarButtonItem(barButton, UIPopoverArrowDirection.Any, true);
else
popover.PresentFromRect(rect, v, UIPopoverArrowDirection.Any, true);
}
return tcs.Task;
}
示例9: ImageViewController
public ImageViewController()
{
Title = "AirPic Demo";
// on iOS 8.x we delegate the AirPlay feature to our Action extension
bool ios8 = UIDevice.CurrentDevice.CheckSystemVersion (8,0);
// the action extension will do the browsing for airplay capable devices
AirPlayBrowser.Enabled = !ios8;
var bounds = UIScreen.MainScreen.Bounds;
image_view = new UIImageView (bounds);
image_view.Image = UIImage.FromFile ("687px-Leontopithecus_rosalia_-_Copenhagen_Zoo_-_DSC09082.JPG");
image_view.Image.Scale (bounds.Size);
Add (image_view);
UIBarButtonItem action = null;
action = new UIBarButtonItem (UIBarButtonSystemItem.Action, delegate {
if (image_view.Image == null)
return;
// UIActivity is only for iOS6+ but that should not limit us :-)
if (UIDevice.CurrentDevice.CheckSystemVersion (6,0)) {
var activities = AirPlayBrowser.Enabled ? UIAirPlayActivity.GetCurrentActivities () : null;
var a = new UIActivityViewController (new [] { image_view.Image }, activities);
if (AppDelegate.RunningOnIPad) {
popup = new UIPopoverController (a);
popup.PresentFromBarButtonItem (action, UIPopoverArrowDirection.Up, true);
} else {
PresentViewController (a, true, null);
}
} else {
var devices = AirPlayBrowser.GetDeviceNames ();
var a = new UIActionSheet (null, null, "Cancel", null, devices);
a.Clicked += (sender, e) => {
nint index = e.ButtonIndex;
// ignore Cancel button
if (index < devices.Length) {
var device = AirPlayBrowser.GetDevice (devices [index]);
if (device != null) // they can disappear anytime
device.SendTo (image_view.Image, null);
}
};
a.ShowFrom (NavigationItem.RightBarButtonItem, true);
}
});
NavigationItem.RightBarButtonItem = action;
}
示例10: Initialize
protected void Initialize()
{
var crews = Create ().ToDictionary(b => b.StartNumber, b => b.Name);
if(crews.Count == 0)
crews = Enumerable.Range (1, 220).ToDictionary (i => i, i => "crew " + i);
_popover = new CrewsDialogViewController(crews);
UIPopoverController myPopOver = new UIPopoverController(_popover);
_popover.Changed += () =>
{
PopulateTable();
};
NavigationItem.RightBarButtonItem = new UIBarButtonItem("Crews", UIBarButtonItemStyle.Plain, null);
NavigationItem.RightBarButtonItem.Clicked += (sender, e) => { myPopOver.PopoverContentSize = new SizeF(450f, 420f);
myPopOver.PresentFromBarButtonItem (NavigationItem.RightBarButtonItem, UIPopoverArrowDirection.Up, true); };
}
示例11: extractImage
void extractImage()
{
imagePicker.FinishedPickingMedia += HandleFinishedPickingMedia;
imagePicker.Canceled += Handle_Canceled;
// show the picker
if (UserInterfaceIdiomIsPhone) {
NavigationController.PresentViewController (imagePicker, true, delegate{});
}
else {
Console.WriteLine ("Popover");
Pc = new UIPopoverController (imagePicker);
Pc.PresentFromBarButtonItem (it, UIPopoverArrowDirection.Up, true);
}
}
示例12: PickFromCamera
public void PickFromCamera()
{
// create a new picker controller
// set our source to the photo library
imagePicker = new UIImagePickerController ();
imagePicker.SourceType = UIImagePickerControllerSourceType.Camera;
// set what media types
imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.Camera);
imagePicker.FinishedPickingMedia += HandleFinishedPickingMedia;
imagePicker.Canceled += Handle_Canceled;
// show the picker
if(UserInterfaceIdiomIsPhone){
NavigationController.PresentViewController (imagePicker, true, delegate {});
}else{
Console.WriteLine("Popover");
Pc = new UIPopoverController(imagePicker);
Pc.PresentFromBarButtonItem(it, UIPopoverArrowDirection.Up, true);
}
}
示例13: share
partial void share (MonoTouch.UIKit.UIBarButtonItem sender)
{
if(shareController == null){
List<UIImage> items = associatedObject.ItemsForSharing();
NSObject [] itemsForSharing = new NSObject [(items == null? 0 : items.Count) + 1];
int i = 0;
if (items!= null) {
for (i = 0; i < items.Count; i++)
itemsForSharing [i] = items [i];
}
itemsForSharing [i] = new NSString (Comment ());
UIActivityViewController activityController = new UIActivityViewController(itemsForSharing, null);
shareController = new UIPopoverController(activityController);
shareController.Delegate = new MyDelegate(this);
shareController.PresentFromBarButtonItem(shareButton, UIPopoverArrowDirection.Any, true);
}
else{
shareController.Dismiss(true);
shareController = null;
}
}
示例14: SendLoginAsync
internal Task<MobileServiceUser> SendLoginAsync(RectangleF rect, object view, MobileServiceAuthenticationProvider provider, JsonObject token = null)
{
if (this.LoginInProgress)
{
throw new InvalidOperationException(Resources.MobileServiceClient_Login_In_Progress);
}
if (!Enum.IsDefined(typeof(MobileServiceAuthenticationProvider), provider))
{
throw new ArgumentOutOfRangeException("provider");
}
string providerName = provider.ToString().ToLower();
this.LoginInProgress = true;
TaskCompletionSource<MobileServiceUser> tcs = new TaskCompletionSource<MobileServiceUser> ();
if (token != null)
{
// Invoke the POST endpoint to exchange provider-specific token for a Windows Azure Mobile Services token
this.RequestAsync("POST", LoginAsyncUriFragment + "/" + providerName, token)
.ContinueWith (t =>
{
this.LoginInProgress = false;
if (t.IsCanceled)
tcs.SetCanceled();
else if (t.IsFaulted)
tcs.SetException (t.Exception.InnerExceptions);
else
{
SetupCurrentUser (t.Result);
tcs.SetResult (this.CurrentUser);
}
});
}
else
{
// Launch server side OAuth flow using the GET endpoint
Uri startUri = new Uri(this.ApplicationUri, LoginAsyncUriFragment + "/" + providerName);
Uri endUri = new Uri(this.ApplicationUri, LoginAsyncDoneUriFragment);
WebRedirectAuthenticator auth = new WebRedirectAuthenticator (startUri, endUri);
auth.ClearCookiesBeforeLogin = false;
UIViewController c = auth.GetUI();
UIViewController controller = null;
UIPopoverController popover = null;
auth.Error += (o, e) =>
{
this.LoginInProgress = false;
if (controller != null)
controller.DismissModalViewControllerAnimated (true);
if (popover != null)
popover.Dismiss (true);
Exception ex = e.Exception ?? new Exception (e.Message);
tcs.TrySetException (ex);
};
auth.Completed += (o, e) =>
{
this.LoginInProgress = false;
if (controller != null)
controller.DismissModalViewControllerAnimated (true);
if (popover != null)
popover.Dismiss (true);
if (!e.IsAuthenticated)
tcs.TrySetCanceled();
else
{
SetupCurrentUser (JsonValue.Parse (e.Account.Properties["token"]));
tcs.TrySetResult (this.CurrentUser);
}
};
controller = view as UIViewController;
if (controller != null)
{
controller.PresentModalViewController (c, true);
}
else
{
UIView v = view as UIView;
UIBarButtonItem barButton = view as UIBarButtonItem;
popover = new UIPopoverController (c);
if (barButton != null)
popover.PresentFromBarButtonItem (barButton, UIPopoverArrowDirection.Any, true);
else
popover.PresentFromRect (rect, v, UIPopoverArrowDirection.Any, true);
//.........这里部分代码省略.........
示例15: ChooseVideoTapped
partial void ChooseVideoTapped(UIBarButtonItem sender)
{
var videoPicker = new UIImagePickerController {
ModalPresentationStyle = UIModalPresentationStyle.CurrentContext,
SourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum,
MediaTypes = new string[] { UTType.Movie }
};
videoPicker.FinishedPickingMedia += (object s, UIImagePickerMediaPickedEventArgs e) => {
displayLink.Paused = true;
playButton.Title = "Play";
popover.Dismiss (true);
outputFrames.Clear ();
presentationTimes.Clear ();
lastCallbackTime = 0.0;
var asset = AVAsset.FromUrl (e.MediaUrl);
if (assetReader != null && assetReader.Status == AVAssetReaderStatus.Reading) {
bufferSemaphore.Release ();
assetReader.CancelReading ();
}
backgroundQueue.DispatchAsync (() => ReadSampleBuffers (asset));
};
videoPicker.Canceled += (object s, EventArgs e) => DismissViewController (true, null);
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) {
popover = new UIPopoverController (videoPicker);
popover.PresentFromBarButtonItem (sender, UIPopoverArrowDirection.Down, true);
}
}