Я смотрю пример Apple MapCallouts для аннотаций и выноски карт (== пузыри, которые появляются, когда вы нажимаете на булавку). У каждой аннотации есть координаты, заголовок и подзаголовок. Я хотел бы отображать субтитры в 2 строки, я пробовал с:
- (NSString *)subtitle
{
return @"Founded: June 29, 1776\nSecond line text";
}
, но текст «Вторая строка текста» остается в одной строке и расширяет пузырь. Я понимаю:
Я также хотел бы изменить изображение на одну из моих собственных, код, который устанавливает эту кнопку, в настоящее время выглядит следующим образом:
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
Есть идеи?
РЕДАКТИРОВАТЬ: Я попробовал совет 7KV7. Смена кнопки прошла успешно, но я все еще не могу получить субтитры в 2 строки. Мой код:
MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier] autorelease];
customPinView.pinColor = MKPinAnnotationColorPurple;
customPinView.animatesDrop = YES;
// Button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 23, 23);
button.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
//UIEdgeInsets titleInsets = UIEdgeInsetsMake(7.0, -20.0, 7.0, 7.0);
//button.titleEdgeInsets = titleInsets;
[button setImage:[UIImage imageNamed:@"ic_phone_default.png"] forState:UIControlStateNormal];
//[button setImage:[UIImage imageNamed:@"ic_phone_selected.png"] forState:UIControlStateSelected];
[button setImage:[UIImage imageNamed:@"ic_phone_selected.png"] forState:UIControlStateHighlighted];
[button addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
customPinView.rightCalloutAccessoryView = button;
//two labels
UIView *leftCAV = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,50)];
//[leftCAV addSubview : button];
UILabel *l1=[[UILabel alloc] init];
l1.frame=CGRectMake(0, 15, 50, 50);
l1.text=@"First line of subtitle";
l1.font=[UIFont fontWithName:@"Arial Rounded MT Bold" size:(10.0)];
UILabel *l2=[[UILabel alloc] init];
l2.frame=CGRectMake(0, 30, 50, 50);
l2.text=@"Second line of subtitle";
l2.font=[UIFont fontWithName:@"Arial Rounded MT Bold" size:(10.0)];
[leftCAV addSubview : l1];
[leftCAV addSubview : l2];
customPinView.leftCalloutAccessoryView = leftCAV;
//customPinView.
customPinView.canShowCallout = YES;
return customPinView;
Я получаю следующее: