【发布时间】:2015-05-22 09:55:49
【问题描述】:
我在这个糟糕的项目上苦苦挣扎了两个星期,但似乎没有任何效果。我必须做一个应用程序,从服务器加载一些单词并将它们呈现为地图上的图钉(MKView)。当用户缩小时,我必须对引脚进行聚类,为此我使用了用 Objective-C 编写的 this-party 库,但我还必须使用按钮制作自定义标注视图。当用户按下所述按钮时,应用程序应该转到 TableViewController,这是我的问题:我无法做到。我在“performSegueWIthIdentifier”之前使用过,效果很好,但现在我收到错误“没有带有'---'标识符的segue”。我知道还有很多其他的线程,但是那里的解决方案都不适合我。此外,我尝试以编程方式实例化 ViewController,但这也不起作用,因为我得到“意外发现 nil ...”,我不知道该怎么做。
我知道我做错了什么,很可能是我如何调用这些函数,但我不知道是什么。这是我到目前为止所尝试的:
在 .xib 文件中我有这个:
import UIKit
class MarkerInfoView: MKAnnotationView {
@IBOutlet weak var theButton: UIButton!
@IBAction func readIt(sender: AnyObject) {
ViewController.goToArticles()
}
}
在 ViewController 中:
class func goToArticles(){
ViewController().reallyGoToArticles()
}
我这样做是因为我找不到其他方法来调用 performSegueWithIdentifier 或 presentViewController
func reallyGoToArticles(){
println("let's go!")
let theArticlesSB = UIStoryboard(name: "Main", bundle: nil)
let vc = theArticlesSB.instantiateViewControllerWithIdentifier("theArticles") as! articlesViewController
self.presentViewController(vc, animated: true, completion: nil)
self.performSegueWithIdentifier("showArticles", sender: self)
}
我已取消注释这两个选项只是为了向您展示。
我已经上传了项目here
非常感谢!
更新
我忘了说如果我把这条线
self.performSegueWithIdentifier("showArticles", sender: self)
在 viewDidLoad 中有效
【问题讨论】:
标签: ios xcode swift mkmapview mapkit