###前提・実現したいこと
お世話になります。
いまObjetive-cでGPS機能を実装中です。
サーバから取得した複数人の座標情報をピン、経路で一括表示しようとしています。
例:
山田のピン、経路(赤色)
佐藤のピン、経路(緑色)
田中のピン、経路(黄色)
###発生している問題・エラーメッセージ
取得した複数の情報をピン、経路表示しようとすると
This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
と出てクラッシュします。
###該当のソースコード
Objective
1 2 // 要素数(ピン数 NSMutableArray) 3 int ct = (int)maTimes.count; 4 CLLocationCoordinate2D coords[ct]; 5 6 for(int j = 0 ; j < ct ; j++){ 7 // pin 8 MyAnnotation* st = [[MyAnnotation alloc] init]; 9 float lla = [NSString stringWithFormat:@"%@",maLatitude[j]].floatValue; 10 float llo = [NSString stringWithFormat:@"%@",maLongitude[j]].floatValue; 11 st.coordinate = CLLocationCoordinate2DMake(lla, llo); 12 st.title = [NSString stringWithFormat:@"%@",msName]; 13 14 // add annotations to map 15 [mk_mv addAnnotation:st]; 16 17 coords[j] = CLLocationCoordinate2DMake(lla, llo); 18 } 19 20 MKPolyline *line = [MKPolyline polylineWithCoordinates:coords count:ct]; 21 22 // add Overlays to map 23 [mk_mv addOverlay:line];
###試したこと
・ピンのみにした場合
// [mk_mv addOverlay:line];
→クラッシュしません。
・一定時間おいて起動後のCPU過多時を避けてみました
→クラッシュしました。
よろしくお願いいたします…。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/03 09:56