Ios MBProgressHub在主线程中运行时,NSNotificationCenter不工作

Ios MBProgressHub在主线程中运行时,NSNotificationCenter不工作,ios,objective-c,grand-central-dispatch,nsnotificationcenter,mbprogresshud,Ios,Objective C,Grand Central Dispatch,Nsnotificationcenter,Mbprogresshud,我正在使用NSNotificationCenter。问题在于,单击按钮时,我会显示MBProgressHUB直到45秒,在此期间,如果服务器未进行任何更改,则不会触发NSNotificationCenter 如果我不使用MBProgressHub通知触发器。下面是我已经实现的代码 dispatch_async(dispatch_get_main_queue(),^() { [[NSNotificationCenter defaultCenter] postNotificationName

我正在使用
NSNotificationCenter
。问题在于,单击按钮时,我会显示
MBProgressHUB
直到45秒,在此期间,如果服务器未进行任何更改,则不会触发
NSNotificationCenter

如果我不使用
MBProgressHub
通知触发器。下面是我已经实现的代码

dispatch_async(dispatch_get_main_queue(),^() {

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

   [[NSNotificationCenter defaultCenter] postNotificationName:@"MqttResponseHomeScreenNotification" object:message.payloadString];
});
当NmbProgressHub运行时,dispatch_Async中的NSNotificationCenter不是tigger


请在此方面提供帮助。

首先在
viewdiload
ViewWillApper
方法中注册
NSNotificationCenter
的对象,如下所示

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

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

首先,在
viewDidLoad
ViewWillApper
方法中注册
NSNotificationCenter
的对象,如下所示

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

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

这就完成了,我的问题是它在没有MBProgressHub的情况下可以正常工作,您可以像[[[UIApplication sharedApplication]delegate]window]addSubview:hud]那样添加MBProgressHub吗;还可以尝试dispatch_async(dispatch_get_main_queue(),^(){[self-performSelectorOnMainThread:@selector(CallNotification)with object:nil waitUntilDone:YES];})-(void)CallNotification{[[NSNotificationCenter defaultCenter]postNotificationName:@“MqttResponseNotification”对象:message.payloadString];[[NSNotificationCenter defaultCenter]postNotificationName:@“MqttResponseHomeScreenNotification”对象:message.payloadString];}完成此操作,我的问题是,如果没有MBProgressHub,它可以正常工作,您可以添加MBProgressHub,比如[[[[UIApplication sharedApplication]委派]窗口]添加子视图:hud];还可以尝试dispatch_async(dispatch_get_main_queue(),^(){[self-performSelectorOnMainThread:@selector(CallNotification)with object:nil waitUntilDone:YES];})-(void)CallNotification{[[NSNotificationCenter defaultCenter]postNotificationName:@“MqttResponseNotification”对象:message.payloadString];[[NSNotificationCenter defaultCenter]postNotificationName:@“MqttResponseHomeScreenNotification”对象:message.payloadString];}