我需要传递一些数据,当应用程序返回到前台时,我已经设法触发该方法,但我无法弄清楚如何触发它在我的ViewController的现有实例中,而不是创建一个新的实例。从AppDelegate访问类的现有实例中的方法
Map.cs
public delegate void beginRefreshMapLine(ReturnRouteTaken returnRouteTaken);
public void updateRouteList(ReturnRouteTaken returnRouteData)
{
coordList = new List<CLLocationCoordinate2D>();
foreach(GPSData point in returnRouteData.GPSData)
{
coordList.Add(new CLLocationCoordinate2D { Latitude = double.Parse(point.Lat), Longitude = double.Parse(point.Lng) });
updateMap(this, new EventArgs());
}
}
这是我需要AppDelegate.cs在目前的情况下引发
AppDelegate.cs方法
if (GlobalVar.BoolForKey("trackMe"))
{
ReturnRouteTaken returnRouteData = webtools.GetRouteTaken(new ReturnRouteTaken() { TestDriveID = GlobalVar.IntForKey("routeTrackedID") });
if (returnRouteData.GPSData.Count > 0)
{
}
}
这里就是我坚持,我曾尝试调查代表并调用这种方法,但我无法理解如何实现它。任何帮助,将不胜感激
可能重复的[如何获得iOS中的所有应用程序的ViewControllers?](http:// stackove rflow.com/questions/14757639/how-to-get-all-the-applications-viewcontrollers-in-ios) – jgoldberger
我在意识到你问到c#之前添加了一个Swift答案。无论如何,看看你的视图控制器订阅UIapplicationWillEnterForeground通知 – Paulw11