我需要傳遞一些數據,當應用程序返回到前臺時,我已經設法觸發該方法,但我無法弄清楚如何觸發它在我的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