[mapView selectAnnotation:firstAnnotation animated:YES];
Run Code Online (Sandbox Code Playgroud)
调试后,此行打印如下
错误:尝试选择尚未添加的注释
此外viewForAnnotation不叫.
问题是什么 ?
任何解决方案
提前致谢.
有人能帮我把这段代码转换成 Swift 吗?
这里我提到了.h和.m在Objective-C 代码中。
Abc是一个UIViewController。我想在我的 Swift 代码中执行这个方法。S怎么可能?
Abc.h
+ (Abc*)sharedInstance;
- (void) startInView:(UIView *)view;
- (void) stop;
Run Code Online (Sandbox Code Playgroud)
Abc.m
static Abc*sharedInstance;
+ (Abc*)sharedInstance
{
@synchronized(self)
{
if (!sharedInstance)
{
sharedInstance = [[Abc alloc] init];
}
return sharedInstance;
}
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)