菜鸟教程小白 发表于 2022-12-11 16:48:33

iOS App 在 segue 崩溃(断点发生在 func prepareForSegue)


                                            <p><p><strong>更新:我发现,仅通过阅读代码很难进行调试,尤其是在这种情况下,<a href="https://www.dropbox.com/s/ty3clsvgednzevj/LoaferMap%20for%20iPhone%20copy%202.zip?dl=0" rel="noreferrer noopener nofollow">https://www.dropbox.com/s/ty3clsvgednzevj/LoaferMap%20for%20iPhone%20copy%202.zip?dl=0</a> ,所以如果您想重现该错误,我会将我的项目上传到 Dropbox。</strong>
<strong>我删除了destination.delete(self),现在它消失了。但应用程序仍然崩溃。我意识到 SliderViewController 中的问题,也许我写的代码根本无法执行。我是初学者,不熟悉 Swift 编程语言。您的帮助对我来说意义重大。</strong></p>

<blockquote>
<p>If you download my project, and look at it. My goal is actually pretty straightforward, you use a slider to select a travel radius, and there are long lines of code generates a random location based on my current location. And finally pass that code to destinationViewController, to display a flyover animation based on the new generated location. But right now I think everything is set up correctly, but the app still crushes. </p>
</blockquote>

<p>当我即将从一个 View 转换到下一个 View 时,我的应用程序崩溃了。 </p>

<pre><code>   override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
         if (segue.identifier == &#34;sendLocationdata&#34;) {
             let destination = segue.destinationViewController as! DestinationViewController
</code></pre>

<blockquote>
<p>Thread 1, Breakpoint 1.1</p>
</blockquote>

<pre><code>   destination.latitude = latitude
   destination.longitude = longitude
          }
</code></pre>

<p>更多源代码在VC中,下一个VC,可以查看我问的另一个问题<a href="https://stackoverflow.com/questions/37980480/how-to-pass-data-from-view-controllers/37980641?noredirect=1#comment63408998_37980641" rel="noreferrer noopener nofollow">How to Pass Data from View Controllers?</a> .</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><pre><code>segue.destinationViewController
</code></pre>

<p>不是destinationViewController
这个类是一个 UINavigationController</p>

<p>你必须为 UINavigationController 的 rootViewController 设置纬度和经度</p>

<p>请像这样编辑</p>

<p> <a href="/image/kaEVT.png" rel="noreferrer noopener nofollow"><img src="/image/kaEVT.png" alt="enter image description here"/></a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于iOS App 在 segue 崩溃(断点发生在 func prepareForSegue),我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/37982076/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/37982076/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS App 在 segue 崩溃(断点发生在 func prepareForSegue)