作者:贺bujak_491 | 来源:互联网 | 2024-10-19 20:22
Hihaveannewbieissuewithobjective-c,cocoa&iPhone.IvedeclaredmapViewinmyapplicatio
Hi have an newbie issue with objective-c, cocoa & iPhone. I've declared mapView in my application delegates applicationDidFinishLaunching:application:
which is instance/pointer of MKMapView
class. mapView
is a member of my application delegate.
大家好,我是objective-c, cocoa & iPhone的新手。我在应用程序委托applicationdidfinishlaunch:application中声明了mapView:application:它是MKMapView类的实例/指针。mapView是我的应用程序委托的成员。
In my view controller in viewDidLoad: I get instance of my application delegate with the following:
在viewDidLoad的视图控制器中:我获得应用程序委托的实例,如下所示:
appDelegate = [[UIApplication sharedApplication] delegate];
My view controller also has got MKMapView *mapView as a member. In viewDidLoad: I try to set it this way:
我的视图控制器也有MKMapView *mapView作为成员。在viewDidLoad:我试图这样设置:
mapView = [appDelegate mapView];
but it seems that I'm not able to get pointer or "reference" to the actual mapView because when I try to [mapView setRegion:region animated:YES];
it does not work. How ever [[appDelegate mapView] setRegion:region animated:YES];
does work.
但似乎我无法获得指向实际mapView的指针或"reference"因为当我尝试[mapView setRegion:region animated:YES];它不工作。如何([appDelegate mapView] setRegion:区域动画:是的);做的工作。
So the question is how do I get a pointer to appDelegates
mapView
from my view controller?
问题是如何从我的视图控制器中获得指向appdelegate mapView的指针?
2 个解决方案