appcoda-tw

Open full view…

用segue將UITableViewCell被點擊到的經緯度傳到地圖顯示地點出現這個錯誤訊息麻煩幫忙解答謝謝

andy9527
Fri, 21 Oct 2016 16:38:07 GMT

'NSInvalidArgumentException', reason: 'Invalid Region <center:+120.49202000, +22.66958800 span:+0.18000000, +0.15000000>' *** First throw call stack: ( 0 CoreFoundation 0x000000010c9c234b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00000001094a321e objc_exception_throw + 48 2 CoreFoundation 0x000000010c9c2299 -[NSException raise] + 9 3 MapKit 0x0000000109e1c18c -[MKMapView setRegion:animated:] + 705 4 Pbike 0x0000000108eaf7a8 _TFC5Pbike19PbikeViewController11viewDidLoadfT_T_ + 1016 5 Pbike 0x0000000108eafd62 _TToFC5Pbike19PbikeViewController11viewDidLoadfT_T_ + 34 6 UIKit 0x000000010a36f06d -[UIViewController loadViewIfRequired] + 1258 7 UIKit 0x000000010a3754d6 -[UIViewController __viewWillAppear:] + 118 8 UIKit 0x000000010a3a0393 -[UINavigationController _startCustomTransition:] + 1290 9 UIKit 0x000000010a3b1008 -[UINavigationController _startDeferredTransitionIfNeeded:] + 697 10 UIKit 0x000000010a3b219b -[UINavigationController __viewWillLayoutSubviews] + 58 11 UIKit 0x000000010a5a91b7 -[UILayoutContainerView layoutSubviews] + 223 12 UIKit 0x000000010a292344 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237 13 QuartzCore 0x000000011245ecdc -[CALayer layoutSublayers] + 146 14 QuartzCore 0x00000001124527a0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 15 QuartzCore 0x000000011245261e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 16 QuartzCore 0x00000001123e062c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280 17 QuartzCore 0x000000011240d713 _ZN2CA11Transaction6commitEv + 475 18 UIKit 0x000000010a1f8878 _afterCACommitHandler + 346 19 CoreFoundation 0x000000010c966e17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 20 CoreFoundation 0x000000010c966d87 __CFRunLoopDoObservers + 391 21 CoreFoundation 0x000000010c94bb9e __CFRunLoopRun + 1198 22 CoreFoundation 0x000000010c94b494 CFRunLoopRunSpecific + 420 23 GraphicsServices 0x000000010e9c8a6f GSEventRunModal + 161 24 UIKit 0x000000010a1cdf34 UIApplicationMain + 159 25 Pbike 0x0000000108eae6cf main + 111 26 libdyld.dylib 0x000000010d8ec68d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

swift
Wed, 07 Dec 2016 09:58:44 GMT

<center:+120.49202000, +22.66958800, span:+0.18000000, +0.15000000> latitude 範圍只有 (-90 to +90) 而longitude 才符合第一個條件(-180 to +180) 有需要可以把CGPoint 換成經緯度才傳到mapview 上 - (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(nullable UIView *)view; 初步死因看來是錯誤的 latitude 導致 Invalid Region