在我的 iOS 项目中,页面有一个 ListView ,需要一些时间才能加载。我想显示加载曲线,如图所示 here但它会禁用整个页面,直到它加载为止。我想让用户在加载过程中使用导航按钮返回。
我现在使用的代码是:
var bounds = UIScreen.MainScreen.Bounds;
loadPop = new LoadingOverlay (bounds);
View.Add (loadPop);
loadingOverlay.Hide ();
有什么办法可以让用户使用导航切换页面,而页面仍然显示加载符号并且数据仍在加载中?
最佳答案
其实很简单。您只需要在列表顶部添加一个 View (带有微调器)并在加载数据时手动将其隐藏。
如果您仍想使用那个 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 ();
关于ios - Xamarin iOS : how to keep the view active when the loading logo in on the screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38382599/