gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 17:34:00 26 4
gpt4 key购买 nike

我在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com