访问故事板内的视图 [英] access view inside a storyboard

查看:122
本文介绍了访问故事板内的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在代码中访问他们从对象浏览器拖动到其故事板中的另一个视图的视图?

How does one access, in code, a view they dragged from the Object Browser into another view in their storyboard?

例如,我创建了一个UIView,我分配给ViewController类。然后我将Map View拖到该视图中。现在我需要开始在代码中操作Map View。我该如何访问它?我已经尝试过像self.view.subview这样的东西但是没有从那里得到任何东西。

For example, I created a UIView which I assigned to a ViewController class. Then I dragged a Map View into that view. Now I need to start manipulating that Map View in code. How do I access it? I've tried things like self.view.subview but haven't gotten anywhere from there.

谢谢。

推荐答案

你应该使用网点,首先选择你的故事板文件,然后转到

You should use outlets, first select your storyboard file, then go to

View->Assistant Editor->Show Assistant Editor

接下来选择地图视图,按控制键盘上的并拖动到将显示.h文件的xcode的右侧部分,将显示以下内容

Next select the map view, press control on your keyboard and drag to the right section of xcode that will show your .h file, the following will appear

在其中写入mapView并点击回车,这将创建一个供你使用
的插座现在你可以使用mapView访问你的MKMapView

Write mapView inside it and hit enter, this will create an outlet for you to use Now you can use mapView to access your MKMapView

这篇关于访问故事板内的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆