自定义弹出窗口不随地图视图移动

时间:2014-07-18 13:14:45

标签: ios mkmapview mkannotationview

我想将信息放在带有自定义标注的地图注释中。

但是地图上的弹出窗口不可移动,它是静态的。

以下是didSelectAnnotationView的代码:

if(![view.annotation isKindOfClass:[MKUserLocation class]])
{
    CGSize  calloutSize = CGSizeMake(180, 106);
    paintView = [[UIView alloc] initWithFrame:CGRectMake(view.frame.origin.x-60, view.frame.origin.y-110, calloutSize.width, calloutSize.height)];

    [paintView setBackgroundColor:[UIColor clearColor]];
    [paintView setUserInteractionEnabled:YES];
    paintView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"map_popup.png"]];


    lblUsername = [[UILabel alloc] initWithFrame:CGRectMake(70, 5, 100, 20)];
    lblUsername.backgroundColor = [UIColor clearColor];
    lblUsername.textAlignment = NSTextAlignmentLeft;
    //lblName.numberOfLines=0;
    [lblUsername setFont:[UIFont fontWithName:@"Roboto-Regular" size:16]];
    lblUsername.lineBreakMode= NSLineBreakByCharWrapping;
    lblUsername.textColor=[UIColor colorWithRed:144/255.0 green:44/255.0 blue:123/255.0 alpha:1];
    lblUsername.text =[arrUserName objectAtIndex:nameInd];
    [paintView addSubview:lblUsername];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button addTarget:self action:@selector(selectAdd)
     forControlEvents:UIControlEventTouchUpInside];

    button.backgroundColor=[UIColor blackColor];
    [button setTitle:@"button" forState:UIControlStateNormal];
    button.frame = CGRectMake(100, 50, 40, 40);
    [view addSubview:button];

    [view addSubview:paintView];
}

0 个答案:

没有答案