Я пытаюсь получить строку titleLabel UIButton, но она регистрируется как CALayer ... какие-либо предложения?
//ADD TWT BUTTON
twitter_share = [[UIButton alloc] initWithFrame:CGRectMake(200, 44, 29, 28)];
twitter_share.backgroundColor = [UIColor clearColor];
[twitter_share setBackgroundImage:[UIImage imageNamed:@"btn_annotation_share_twitter.png"] forState:UIControlStateNormal];
twitter_share.titleLabel.hidden = YES;
twitter_share.titleLabel.alpha = 0;
twitter_share.tag = 20;
[twitter_share setTitle:@"test!" forState:UIControlStateNormal];
UITapGestureRecognizer *tap_twt = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinButtonTap:)];
tap_twt.numberOfTapsRequired = 1;
[twitter_share addGestureRecognizer:tap_twt];
[tap_twt release];
[annotationView addSubview:twitter_share];
- (void) handlePinButtonTap:(UITapGestureRecognizer *)gestureRecognizer {
UIButton *btn = (UIButton *) gestureRecognizer.view;
MKAnnotationView *av = (MKAnnotationView *)[btn superview];
id<MKAnnotation> ann = av.annotation;
NSLog(@"handlePinButtonTap: ann.title=%@", ann.title);
NSString *testBtn = [NSString stringWithFormat:@"%@", [btn titleLabel]];
NSLog(@"handlePinButtonTap: btn title=%@", testBtn);
}
Журнал:
handlePinButtonTap: btn title=<UIButtonLabel: 0x70a14d0; frame = (0 3; 29 22); text = 'test!'; clipsToBounds = YES; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x70a6930>>