在我MainMainViewController
我創造了新的UIView(ContentView
)。我設置了調用方法來定位錯誤
DetailViewController *detailView =
[[DetailViewController alloc] initWithObject:paAnnotation];
detailView.view.frame = CGRectMake(0,
0,
[self getWidthOfScreen],
[self getWidthOfScreen]);
[contentView addSubview:detailView.view];
它工作正常,但在我的DetailViewController
中,我創建了UIButton並設置了目標操作。但是當我點擊按鈕時,它崩潰並顯示錯誤。你能告訴我哪裏可以解決問題嗎?
- (id)initWithObject:paAnnotation {
if ((self = [super init])) {
self.annotation = paAnnotation;
}
return self;
}
- (void)viewDidAppear:(BOOL)animated {
UIButton *closeButton = [[UIButton alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];
closeButton.backgroundColor = [UIColor redColor];
[closeButton addTarget:self
action:@selector(closeContent)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:closeButton];
}
- (void)closeContent {
NSLog(@"Test");
}
錯誤:
-[GEOVectorTile closeContent]: unrecognized selector sent to instance 0x19d0a1e0
你tryied設置裏面'viewDidLoad'按鈕? –
是的,我試過,但沒有工作相同的錯誤。 –