大家好,我一个与地图相关的app,需要进行界面的传值,下面是代码:
界面一:
class HomeViewController: UIViewController, MKMapViewDelegate {
func JumpToSearchViewBtn () {
HomeVIew.removeFromSuperview()
// let MainStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
// Jump2SearchView.SelectedCity = CitySelectBtn.titleForState(UIControlState.Normal)!
// let Jump2SearchView = MainStoryboard.instantiateViewControllerWithIdentifier("SearchView")
// Jump2SearchView let Jump2SearchView = SearchViewController() self.presentViewController(Jump2SearchView, animated: true, completion: nil)
}
下面是didload里面一些代码 应该没问题,因为用注释掉的方法写的没有bug
}界面二:
import UIKit
import MapKit
class SearchViewController: UIViewController {
@IBOutlet weak var SearchUserView: MKMapView!
var SelectedCity:String = "" override func viewDidAppear(animated: Bool) { SearchUserView.delegate = self
}
多余的代码就不写了
这个方法能传值,但是运行到delegate这里就报错
fatal error: unexpectedly found nil while unwrapping an Optional value
关于mapview的好像都有问题.....
不知道是什么原因,请大神指点
界面一:
class HomeViewController: UIViewController, MKMapViewDelegate {
func JumpToSearchViewBtn () {
HomeVIew.removeFromSuperview()
// let MainStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
// Jump2SearchView.SelectedCity = CitySelectBtn.titleForState(UIControlState.Normal)!
// let Jump2SearchView = MainStoryboard.instantiateViewControllerWithIdentifier("SearchView")
// Jump2SearchView let Jump2SearchView = SearchViewController() self.presentViewController(Jump2SearchView, animated: true, completion: nil)
}
下面是didload里面一些代码 应该没问题,因为用注释掉的方法写的没有bug
}界面二:
import UIKit
import MapKit
class SearchViewController: UIViewController {
@IBOutlet weak var SearchUserView: MKMapView!
var SelectedCity:String = "" override func viewDidAppear(animated: Bool) { SearchUserView.delegate = self
}
多余的代码就不写了
这个方法能传值,但是运行到delegate这里就报错
fatal error: unexpectedly found nil while unwrapping an Optional value
关于mapview的好像都有问题.....
不知道是什么原因,请大神指点
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货