2016-07-12 13 views
0

Ich beginne die Entwicklung für iOS mit Xamarin.iOS und ich möchte wissen, ob es einen ProgressDialog von Android-Äquivalent in iOS gibt?ProgressDialog Equivalent für iOS

Mit anderen Worten, ich möchte eine modale wie dies in iOS erstellen: enter image description here

Antwort

2

Ich denke,

https://components.xamarin.com/view/mbprogresshud/

ist die beste Option. Sie können die Informationen von hier

https://components.xamarin.com/gettingstarted/mbprogresshud

EDIT 1

Hier ist eine statische Klasse von mir geschrieben finden. Hope wird Ihnen helfen

using CoreGraphics; 
using MBProgressHUD; 
using System; 
using System.Collections.Generic; 
using System.Text; 
using UIKit; 
namespace CandyCaneClub.iOS.Helper 
{ 
/* 
A generic helper class to show and hide the overlay for running processes on application 
*/ 
    public class OverlayHelper 
    { 
     public static MTMBProgressHUD overlay; 
     //Initialize the Overlay with string as a message to show and view on which we suppose to show 
     public static MTMBProgressHUD InitOverlay(string message, UIView view) 
     { 
      overlay = new MTMBProgressHUD(view) 
      { 
       LabelText = message, 
       RemoveFromSuperViewOnHide = true 
      }; 
      overlay.Alpha = 0.75f; 
      view.AddSubview(overlay); 
      overlay.Show(animated: true); 
      return overlay; 
     } 
     //Hide the overlay 
     public static void HideOverlay() 
     { 
      if(overlay != null) 
      overlay.Hide(animated: true, delay: 2); 
     } 
    } 
} 
+0

Eine Antwort mit Beispiel aktualisiert – PrafulD

0

This Xamarin.IOS documentation link sollten Sie geben, was Sie einen Fortschrittsdialog aufbauen müssen. In ihrem Beispiel nimmt der Fortschrittsdialog den gesamten Bildschirm ein, aber mit einigen der Parameter können Sie optimieren, dass Sie im Grunde aussehen, was Sie wollen.

1

Xamarin hat ein komplettes Rezept für diese genaue Ansicht geschrieben. https://developer.xamarin.com/recipes/ios/standard_controls/popovers/display_a_loading_message/

public class LoadingOverlay : UIView { 

    // control declarations 
    UIActivityIndicatorView activitySpinner; 
    UILabel loadingLabel; 

    public LoadingOverlay (CGRect frame) : base (frame) 
    { 
     // configurable bits 
     BackgroundColor = UIColor.Black; 
     Alpha = 0.75f; 
     AutoresizingMask = UIViewAutoresizing.All; 

     nfloat labelHeight = 22; 
     nfloat labelWidth = Frame.Width - 20; 

     // derive the center x and y 
     nfloat centerX = Frame.Width/2; 
     nfloat centerY = Frame.Height/2; 

     // create the activity spinner, center it horizontall and put it 5 points above center x 
     activitySpinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge); 
     activitySpinner.Frame = new CGRect (
      centerX - (activitySpinner.Frame.Width/2) , 
      centerY - activitySpinner.Frame.Height - 20 , 
      activitySpinner.Frame.Width, 
      activitySpinner.Frame.Height); 
     activitySpinner.AutoresizingMask = UIViewAutoresizing.All; 
     AddSubview (activitySpinner); 
     activitySpinner.StartAnimating(); 

     // create and configure the "Loading Data" label 
     loadingLabel = new UILabel(new CGRect (
      centerX - (labelWidth/2), 
      centerY + 20 , 
      labelWidth , 
      labelHeight 
      )); 
     loadingLabel.BackgroundColor = UIColor.Clear; 
     loadingLabel.TextColor = UIColor.White; 
     loadingLabel.Text = "Loading Data..."; 
     loadingLabel.TextAlignment = UITextAlignment.Center; 
     loadingLabel.AutoresizingMask = UIViewAutoresizing.All; 
     AddSubview (loadingLabel); 

    } 

    /// <summary> 
    /// Fades out the control and then removes it from the super view 
    /// </summary> 
    public void Hide() 
    { 
     UIView.Animate (
      0.5, // duration 
      () => { Alpha = 0; }, 
      () => { RemoveFromSuperview(); } 
     ); 
    } 
} 

enter image description here