0

我目前正在尝试在 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];
}

提前致谢 ...

4

1 回答 1

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];
}
于 2012-10-28T10:36:49.343 回答