【问题标题】:Xamarin iOS: how to keep the view active when the loading logo in on the screenXamarin iOS:如何在屏幕上加载徽标时保持视图处于活动状态
【发布时间】:2016-07-14 19:23:30
【问题描述】:

在我的 iOS 项目中,页面有一个列表视图,需要一些时间才能加载。我想像here 那样显示加载曲线,但它会禁用整个页面,直到它加载。我想让用户在加载过程中使用导航按钮返回。

我现在使用的代码是:

var bounds = UIScreen.MainScreen.Bounds; 
loadPop = new LoadingOverlay (bounds);
View.Add (loadPop);
loadingOverlay.Hide ();

有什么方法可以让用户使用导航来切换页面,同时页面仍然显示加载符号并且数据仍在加载中?

【问题讨论】:

  • 如果您希望用户能够导航离开,为什么要用加载视图覆盖整个屏幕?
  • 是否可以为特定视图设置边界,即仅用于列表视图并让用户有机会返回导航(如果选择)?如果是,我该如何设置?

标签: ios xamarin uinavigationcontroller navigation xamarin.ios


【解决方案1】:

其实很简单。您只需要在列表顶部添加一个视图(使用微调器)并在加载数据时手动隐藏它。 如果您仍想使用该 LoadingOverlay 示例,请修改 bounds 参数:

var navigationBarHeight = 48; // not sure what´s the actual height. Google it!
var bounds = UIScreen.MainScreen.Bounds; 
loadPop = new LoadingOverlay (new CGRect(bounds.X, navigationBarHeight, bounds.Width, bounds.Height - navigationBarHeight);
View.Add (loadPop);

如果您只需要微调器,您还可以从您提供的链接中获取一些代码:

activitySpinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge); // change color here
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 ();

【讨论】:

  • 谢谢。如果不需要,我不想使用LoadingOverlay 示例。如您所述,我怎样才能添加一个视图(使用微调器)?
  • @xleon 我面临的问题是,当加载指示器存在时,我可以单击后退按钮和右导航栏按钮。我希望加载指示器覆盖整个屏幕。我使用了 Xamarin 文档 (developer.xamarin.com/recipes/ios/standard_controls/popovers/…) 中提供的相同代码,而没有减去导航栏的高度。知道为什么会这样吗?
猜你喜欢
  • 2012-07-17
  • 2012-05-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-18
  • 1970-01-01
  • 2022-06-28
  • 2021-11-17
相关资源
最近更新 更多