iphone - MapView 高于 iOS 应用程序中的所有对象

标签 iphone objective-c ios mapkit

我在 nib 文件的 View 中有一个 mapView,委托(delegate)设置为文件的所有者,导出设置为 IBOutlet MKMapView* mapView;

我遇到的问题是 map 高于所有其他对象。如果我添加 UIView,您将看不到它,因为它位于 map 下方。

知道为什么会发生这种情况吗?我以前没有遇到过这个问题

谢谢。

最佳答案

答案很简单,您需要将创建的对象作为 subview 添加到 MapView。

例如,下面是您将 UILabel 添加到 MapView 的方法。只需在 init 中执行此操作

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Create the label
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 320)];
    label.backgroundColor = [UIColor whiteColor];
    label.text = @"I'm on top of the Map!";

    // Add the label to the mapView
    [self.mapView addSubview:label];

    // Release the label if you are not using ARC
    [label release];
}

编辑:请记住,此概念适用于其他对象,例如 UISegmentedControl。

关于iphone - MapView 高于 iOS 应用程序中的所有对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10643768/

相关文章:

ios - 如何让 UITableView 请求可见表格之外的 X 个下一个单元格?

objective-c - 获取 TableView 的标题titleForHeaderInSection

iphone - 更改 UInavigationbar 标题后页

ios - 像音乐应用一样向下滑动

ios - 在 Newsstand 应用程序中通知用户下载已完成

ios - MPMediaPickerController 自定义标签和图标的颜色

iphone - 以横向模式启动应用程序时 UIOrientation 不起作用

iphone - Objective C - NSArray 和 For 循环结构

ios - Swift 默认的 AlertViewController 打破约束

iPhone:viewWillAppear 仅在从其他 View 返回时出现