在viewdidload裡面我加了兩條Thread
[NSThread detachNewThreadSelector:@selector(gotortsp) toTarget:self
withObject:nil];
dispatch_queue_t mainQueue = dispatch_get_main_queue();
dispatch_async(mainQueue, ^{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(getUserProfileSuccess:)
name:@"Notification_GetUserProfileSuccess" object:nil]; });
-(void)gotortsp
{
[self runrtsp];
}
- (void) getUserProfileSuccess: (NSNotification*) aNotification
{
NSLog(@"in");
[self.spinner stopAnimating];
self.DisplaytoImage = [aNotification object];
}
由於runrtsp是建立一個live555連線一直傳封包進來讓ffmpeg解碼 解完碼再藉由
notification回傳到這裏的imageview update ui
我把回傳的寫在dispatch_get_main_queue();
為什麼沒辦法更新ui呢@@
可是log卻有印in的訊息 代表他有進來 但是卻沒有更新ui
由於runrtsp是個一直持續不間斷的收封包 所以只能做callback回來更新ui
因為不間斷 所以無法使用dispatch_queue_create()會一直卡在裡面...
應該要怎麼做才能夠確實的更新ui呢...拜託各位幫我解答了