在MkMapView上添加AwesomeMenu

时间:2012-09-25 16:08:40

标签: ios mkmapview mapkit subview addsubview

我目前正在尝试在MapView上添加AwesomeMenu。 mapview通过Storyboard加载,AwesomeMenu在视图控制器的“viewDidLoad”方法中创建,然后作为子视图添加。 这样AwesomeMenu就不会在视图上显示,在向MKMapView添加子视图时是否存在特殊问题?任何线索?

-(void)viewDidLoad
{
    CLLocation *turin = [[CLLocation alloc] initWithLatitude:45.071274 longitude:7.684910];
    MKCoordinateRegion region =
    MKCoordinateRegionMakeWithDistance (
                                    turin.coordinate, 1000, 1000);
    [mapView setRegion:region animated:NO];
    [switcher addTarget:self action:@selector(populateMap:) forControlEvents:UIControlEventValueChanged];
    menu = [[AwesomeMenu alloc] initWithFrame:self.mapView.frame
                                                 menus:nil];
    [self.mapView addSubview:menu];
}

提前致谢...

1 个答案:

答案 0 :(得分:2)

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIImage *storyMenuItemImage = [UIImage imageNamed:@"bg-menuitem.png"];
    UIImage *storyMenuItemImagePressed = [UIImage imageNamed:@"bg-menuitem-highlighted.png"];
    UIImage *starImage = [UIImage imageNamed:@"icon-star.png"];


    AwesomeMenuItem *starMenuItem1 = [[AwesomeMenuItem alloc] initWithImage:storyMenuItemImage
                                                           highlightedImage:storyMenuItemImagePressed
                                                               ContentImage:starImage
                                                    highlightedContentImage:nil];

    NSArray *menuOptions = [NSArray arrayWithObjects:starMenuItem1 , nil];
    AwesomeMenu *menu = [[AwesomeMenu alloc] initWithFrame:self.view.frame
                                                     menus: menuOptions];

    [self.view addSubview:menu];
}