1

Je travaille avec le NSNotificationCenter. Le problème est sur le clic de bouton que j'ai montré le MBProgressHUB jusqu'à 45 secondes, Entre ceci si le serveur fait n'importe quels changements NSNotificationCenter n'est pas des déclencheurs.NSNotificationCenter ne fonctionne pas lorsque MBProgressHub est en cours d'exécution dans le thread principal

Si je n'utilise pas le MBProgressHub les déclencheurs de notification. Ci-dessous le code que j'ai implémenté.

dispatch_async(dispatch_get_main_queue(),^() { 

    [[NSNotificationCenter defaultCenter] postNotificationName:@"MqttResponseNotification" object:message.payloadString]; 

    [[NSNotificationCenter defaultCenter] postNotificationName:@"MqttResponseHomeScreenNotification" object:message.payloadString]; 
}); 

la NSNotificationCenter à l'intérieur du dispatch_Async ne sont pas en cours d'exécution Tigrou whenMBProgressHub est.

S'il vous plaît aidez-nous dans cela.

Répondre

0

D'abord, vous enregistrez l'objet pour NSNotificationCenter dans viewDidLoad ou ViewWillApper méthode comme ci-dessous.

- (void)viewDidLoad { 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MqttResponseHomeScreenNotification Method:) name:@"MqttResponseHomeScreenNotification" object:nil]; 
} 

- (void) MqttResponseHomeScreenNotification Method:(NSNotification *) notification { 
} 
+0

cela se fait, mon problème est-il fonctionne très bien avec avec des MBProgressHub, – nikey

+0

pouvez-vous s'il vous plaît ajouter MBProgressHub comme [la fenêtre [[[UIApplication sharedApplication] délégué]] de addSubview: hud]; –

+0

également essayer dispatch_async (dispatch_get_main_queue(), ^() { [auto performSelectorOnMainThread: @selector (CallNotification) withObject: néant waitUntilDone: OUI]; }); - (void) {CallNotification [[NSNotificationCenter defaultCenter] postNotificationName: @ "MqttResponseNotification" objet: message.payloadString]; [[NSNotificationCenter defaultCenter] postNotificationName: @ "MqttResponseHomeScreenNotification" objet: message.payloadString]; } –