2015-10-26 13 views
8

Aggiornamento 29 ottobre 2015: Forse è stato possibile trovare la causa di ciò. Sto creando un livello sfumatura in base a this StackOverflow post - funziona perfettamente per me e per tutti gli altri con cui ho provato, ma potrebbero esserci problemi con altre persone?Arresto dell'app iPhone: UIKit

CAGradientLayer * g = [CAGradientLayer layer]; 
UIColor * colourFrom = [UIColor colorWithRed:0.1 green:0.7 blue:0.3 alpha:1.0]; 
UIColor * colourTo = [UIColor colorWithRed:0.1 green:0.8 blue:0.4 alpha:1.0]; 

g.frame  = self.view.bounds; 
g.cornerRadius = 10; 
g.startPoint = CGPointMake(0.0, 0.5); 
g.endPoint  = CGPointMake(1.0, 0.5); 
g.colors  = [NSArray arrayWithObjects:(id)[colourFrom CGColor], 
              (id)[colourTo CGColor], 
              nil]; 

Aggiornamento 27 ottobre 2015: Ancora vedere questi incidenti provenienti da Crashlytics.


Aggiornamento 26 ottobre 2015: Ho trovato this thread on StackOverflow che sembra essere esattamente lo stesso problema che sto avendo (ma senza risposte ..), ma stanno usando fogli di azione di Facebook/Twitter cui sono non. Solo qualcosa per aiutare a diagnosticare il problema.


appena rilasciato un app per l'App Store e stiamo assistendo a una piccola percentuale di utenti (~ 2%) con questo incidente in Crashlytics:

Sembra che è solo che appare con iOS 9, ma sta accadendo su tutti i dispositivi.

Eccezione irreversibile: NSInternalInconsistencyException Solo gli spazi colore RGBA o bianco sono supportati in questa situazione.

Personalmente sto eseguendo un iPhone 6 con 9.1 e non sto riscontrando il problema. Ho anche provato in simulatori e ancora nessun problema, quindi non sono sicuro di come questo bug si stia effettivamente accumulando. La traccia dello stack da Crashlytics è sotto.

Sembra che uno UIColor sia stato aggiunto a un NSDictionary senza essere codificato, ma non lo sto facendo da nessuna parte nell'app. Sembra anche che potrebbe avere qualcosa a che fare con UIRemoteViewController, ma non sto usando quello nell'app (a meno che l'accesso con Facebook non lo faccia - ho provato ad accedere con Facebook al telefono e ai simulatori, ma di nuovo non posso ottenere questo errore per apparire).

Qualcuno ha idea di cosa potrebbe causare questo?


Thread : Fatal Exception: NSInternalInconsistencyException 
0 CoreFoundation     6512725832 __exceptionPreprocess 
1 libobjc.A.dylib    6869942144 objc_exception_throw 
2 CoreFoundation     6512725528 +[NSException raise:format:] 
3 Foundation      6528403996 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] 
4 UIKit       6606881444 -[UIColor encodeWithCoder:] 
5 Foundation      6528169072 _encodeObject 
6 Foundation      6528197336 +[NSKeyedArchiver archivedDataWithRootObject:] 
7 UIKit       6609904352 -[_UIAppearanceRecorder _recordInvocation:withClassName:containerClassNames:traitCollection:selectorString:forRemoteProcess:] 
8 UIKit       6609884356 __54+[_UIAppearance _recordersExcludingSource:withWindow:]_block_invoke 
9 CoreFoundation     6511594744 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke 
10 CoreFoundation     6511594448 -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] 
11 UIKit       6609883592 +[_UIAppearance _recordersExcludingSource:withWindow:] 
12 UIKit       6611900724 UIViewServiceCurrentAppearanceSerializedRepresentations 
13 UIKit       6610654700 +[_UIRemoteViewController _requestViewController:traitCollection:fromServiceWithBundleIdentifier:service:connectionHandler:] 
14 UIKit       6610654160 +[_UIRemoteViewController requestViewControllerWithService:connectionHandler:] 
15 UIKit       6609355772 __117-[NSExtension(UIViewControllerAdditions) instantiateViewControllerWithInputItems:listenerEndpoint:connectionHandler:]_block_invoke_2 
16 libdispatch.dylib    6878402280 _dispatch_call_block_and_release 
17 libdispatch.dylib    6878402216 _dispatch_client_callout 
18 libdispatch.dylib    6878424496 _dispatch_main_queue_callback_4CF 
19 CoreFoundation     6512427512 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 
20 CoreFoundation     6512418912 __CFRunLoopRun 
21 CoreFoundation     6511561888 CFRunLoopRunSpecific 
22 GraphicsServices    6701891720 GSEventRunModal 
23 UIKit       6602887164 UIApplicationMain 
24 MyApp       4296179280 main (main.m:16) 
25 libdyld.dylib     6878603448 start 

aggiornamento con esempi di codice

questo è chiamato nel application:didFinishLaunchingWithOptions:

// Make the app look pretty 
// Turn the status bar color white 
[[UIApplication sharedApplication] setStatusBarHidden:NO]; 
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 
// Nav bar: Background colour 
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0]]; 
// Nav bar: White text 
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:1.0], NSForegroundColorAttributeName, nil]]; 
// Nav bar: Tint colour 
[UINavigationBar appearance].tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TintNavBar"]]; 
// Tab Bar: Background color 
[[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0]]; 
// Tab bar: Tint colour 
[UITabBar appearance].tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"gradientSmall"]]; 
// UIControlSegment: Change the colours to just white 
// @url https://stackoverflow.com/a/21484829/4027036 
[[UISegmentedControl appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[Ui getColour:UI_BODY_PRIMARY]} 
               forState:UIControlStateNormal]; 
+0

È possibile inserire la riga di codice in cui si verifica questo arresto anomalo? – Sujania

+0

@Sujania No, poiché non sono sicuro da dove provenga effettivamente - Non riesco a riprodurlo e la traccia dello stack non indica dove sia. – cjhill

+0

come da mia lettura questo è l'errore con UIApperence o [UIColor colorWithPatternImage:] – Nik

risposta

3

come per le mie letture questo è l'errore con UIApperence o [UIColor colorWithPatternImage:] in ios 6

quindi controllare con quello nel codice. se hai quel codice nella tua app, usa il colore pieno.

qui sono alcuni dei link da cui sono arrivato fino a questa conclusione:

1) IOS erro at Posting to Facebook with the native Share dialog - UICGColor encodeWithCoder

2) UIApperance and various crashes

3) UIApperance and various crashes

4) iOS 6 MFMailComposeViewController: Only support RGBA or the White color space, this method is a hack

+0

È possibile, sto impostando 'colorWithPatternImage' in' UIApperence' ... tuttavia l'app è disponibile solo su iOS 7+, e Crashlytics lo segnala come solo arresto anomalo su dispositivi iOS 9 (9.0, 9.0.2 e 9.1). – cjhill

+0

ti preghiamo di postare qualche codice riguardo a quale controllo stai impostando UIAppearance. puoi provare ad impostare l'aspetto come questo. [[UINavigationBar appearance] setBackgroundImage: [UIImage imageNamed: @ "nav_bar"] forBarMetrics: UIBarMetricsDefault]; – Nik

+0

Certo, ho modificato il mio post originale - è in fondo. – cjhill

1

Il tuo problema è che i colori dei pattern non possono essere codificati tramite l'implementazione UIColor's di NSCoding. Il loro spazio colore è kCGColorSpaceModelPattern che, come dice il messaggio, si interrompe NSCoding e quindi non è consentito.

Questo può essere dimostrato trivally eseguendo questo codice:

UIColor* color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"whatever"]]; 
NSData* data = [NSKeyedArchiver archivedDataWithRootObject:color]; 

Questo fa esplodere in [UIColor encodeWithCoder] con lo stesso fallimento assert.

Per quanto riguarda il motivo per cui UIColors vengono codificati, questo è meno chiaro. Molto probabilmente con _UIAppearanceRecorder, ma il signore sa cosa. Basta smettere di usare i colori del modello e dovresti stare bene.

Problemi correlati