2016-12-24 4 views
1

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에 대한 코드를 코드 라인입니다.

+1

나는 xamarin 녀석이 아니지만 이것이 블록 기반 'NSTimer' API로 변환되는지 궁금합니다. iOS 10에 도입 된 ['scheduledTimer (withTimeInterval : 반복 : 블록 :)'] (https://developer.apple.com/reference/foundation/timer/2091889-scheduledtimer)). 이전' target '/'selector'변환을 지원합니다. – Rob

+0

@Kyll 괜찮아. –

답변

2

@Rob이 맞습니다. iOS 9 이하를 타겟팅하는 경우 다른 방법을 사용해야합니다.

이 코드 아이폰 OS (10)에 종래의 iOS 버전을 사용할 수없는 신규 블록 구문 구현으로 변환 :

[ObjCRuntime.Introduced (ObjCRuntime.PlatformName.iOS, 10, 0, ObjCRuntime.PlatformArchitecture .None), 널 (null)

https://developer.xamarin.com/api/member/Foundation.NSTimer.CreateScheduledTimer/p/System.Double/System.Boolean/System.Action%7BFoundation.NSTimer%7D/

+0

이전 iOS 버전에서 사용할 수있는 대체 방법이 있습니까? – Darshana

+0

@ darshana 제 9.3 응용 프로그램은 Nstimer와 함께 쉽게 Part! – UserID0908