Xamarinで開発されたiOSアプリケーションでNSTimer
を使用しています。アプリはiOS 10(iPhone 5S)でもうまく動作していますが、iOS 9.3.5を搭載したiPadでクラッシュします。
なぜこのようなことが起こり、どうすれば解決できますか?NSTimer - iOS 10では動作しますが、iOSでは動作しません9.3
は、ここでは、コードです:
timer = NSTimer.CreateScheduledTimer(0.3, true, delegate
{
List<String> keys = this.beaconRegions.Keys.ToList();
foreach (string identifier in keys)
{
this.locationManager.StopRangingBeacons((CLBeaconRegion)this.beaconRegions[identifier]);
this.locationManager.StopMonitoring(this.beaconRegions[identifier]);
this.locationManager.StartMonitoring(this.beaconRegions[identifier]);
this.locationManager.StartRangingBeacons(this.beaconRegions[identifier]);
}
});
そしてここでクラッシュログの詳細です:
4 CoreFoundation 0x21c9a234 0x21c72000 + 164404
5 iBeacon 0x0023564c wrapper_managed_to_native_ObjCRuntime_Messaging_objc_msgSend_intptr_intptr_double_bool_intptr (/<unknown>:1)
6 iBeacon 0x001e8ecc Foundation_NSTimer_CreateScheduledTimer_double_bool_System_Action_1_Foundation_NSTimer (NSTimer.g.cs:134)
7 iBeacon 0x001de5b4 iBeacon_LocationManager_turnOnMonitoring (LocationManager.cs:277)
8 iBeacon 0x001de2ac iBeacon_LocationManager_startMonitoringForBeacons (LocationManager.cs:250)
LocationManager.cs:277
- これは私がNStimer
ためのコードを持っているコードの行です。
私はxamarinの人間ではありませんが、これはブロックベースのNSTimer APIに変換されているのでしょうか? iOS 10で導入された['scheduledTimer(withTimeInterval:repeats:block:)'](https://developer.apple.com/reference/foundation/timer/2091889-scheduledtimer))は、以前のiOSバージョンをサポートしようとしている場合は、「ターゲット」/「セレクタ」レンディションを使用します。 – Rob
@Kyll okそれを得ました。 –