Xamarin iOS:如何在屏幕上加载徽标时保持视图处于活动状态
Xamarin iOS: how to keep the view active when the loading logo in on the screen
在我的 iOS 项目中,页面有一个列表视图,需要一些时间才能加载。我想显示加载曲线,如图所示 here 但它会禁用整个页面,直到它加载为止。我想让用户在加载过程中使用导航按钮返回。
我现在使用的代码是:
var bounds = UIScreen.MainScreen.Bounds;
loadPop = new LoadingOverlay (bounds);
View.Add (loadPop);
loadingOverlay.Hide ();
有什么办法可以让用户使用导航切换页面,而页面仍然显示加载符号并且数据仍在加载中?
其实很简单。您只需要在列表顶部添加一个视图(带有微调器)并在加载数据时手动将其隐藏。
如果您仍想使用那个 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);
如果您只需要微调器,您还可以从您提供的 link 中获取一些代码:
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 项目中,页面有一个列表视图,需要一些时间才能加载。我想显示加载曲线,如图所示 here 但它会禁用整个页面,直到它加载为止。我想让用户在加载过程中使用导航按钮返回。
我现在使用的代码是:
var bounds = UIScreen.MainScreen.Bounds;
loadPop = new LoadingOverlay (bounds);
View.Add (loadPop);
loadingOverlay.Hide ();
有什么办法可以让用户使用导航切换页面,而页面仍然显示加载符号并且数据仍在加载中?
其实很简单。您只需要在列表顶部添加一个视图(带有微调器)并在加载数据时手动将其隐藏。
如果您仍想使用那个 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);
如果您只需要微调器,您还可以从您提供的 link 中获取一些代码:
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 ();