1
こんにちは、私はちょうどMTLocationここに来た:https://github.com/darkseed/MTLocation。MTLocation how-to
ナビゲーションバーに配置されているアプリケーションでロケートボタンを使用したいと思います。このボタンを押すと地図が現在の場所に移動します。
// Configure Location Manager
[MTLocationManager sharedInstance].locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[MTLocationManager sharedInstance].locationManager.distanceFilter = kCLDistanceFilterNone;
[MTLocationManager sharedInstance].locationManager.headingFilter = 5; // 5 Degrees
// create locate-me item
MTLocateMeBarButtonItem *locateMeItem = [[[MTLocateMeBarButtonItem alloc] initWithLocationStatus:MTLocationStatusIdle] autorelease];
// set delegate that is called when mode of Button changes
locateMeItem.delegate = [MTLocationManager sharedInstance];
// add target-action
[locateMeItem addTarget:self action:@selector(myCustomSelector:) forControlEvents:UIControlEventTouchUpInside];
// disable heading
locateMeItem.headingEnabled = NO;
// create array with ToolbarItems
NSArray *toolbarItems = [NSArray arrayWithObject:locateMeItem];
// set toolbar items
[self.toolbar setItems:toolbarItems animated:NO];
ツールバーで私を見つけ、ボタンを表示素晴らしいですが、どのように我々は、この作品は、GPSによる現在位置を表示するように作ることができます。
著者は、このようなコードを使用することを提案していますか?私は、私たちはmyCustomSelectorメソッドを実装する必要があると思いますが、私は方法がわかりません。どんな助け? (
- (void) myCustomSelector:(MTLocateMeBarButtonItem*) button {
[self.mapView setCenterCoordinate:self.mapView.userLocation.location.coordinate];
}
あなたは別のボタンモードで適切な機能の世話をする必要があります