Я пытаюсь создать подкласс UIButton, чтобы присоединить к нему свойство, но, как вы уже могли догадаться, я получаю ошибку «неопознанный селектор отправлен в экземпляр».
Точная ошибка: [UIButton setAnnotPin:]: нераспознанный селектор отправлен в экземпляр
Вот важные части кода:
MapViewController.h:
#import "UIRightPinAccessoryButton.h"
MapViewController.m:
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
//some other code..
UIRightPinAccessoryButton *rightAccessoryButton = [UIRightPinAccessoryButton buttonWithType:UIButtonTypeDetailDisclosure];
rightAccessoryButton.frame = CGRectMake(0, 0, 35, 35);
rightAccessoryButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
rightAccessoryButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[rightAccessoryButton addTarget:self action:@selector(rightAccessoryButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
rightAccessoryButton.annotPin = annot; **// Error comes here**
}
и вот мой класс UIRightPinAccessoryButton:
UIRightPinAccessoryButton.h
#import "Annotations.h"
@interface UIRightPinAccessoryButton : UIButton{
Annotations *annotPin;
}
@property (nonatomic) Annotations *annotPin;
UIRightPinAccessoryButton.m
#import "UIRightPinAccessoryButton.h"
@implementation UIRightPinAccessoryButton
@synthesize annotPin;
@end
Я действительно не понимаю, почему xcode ищет метод setAnnotPin: в UIButton вместо моего пользовательского UIRightPinAccessoryButton ??