creating a view on a background thread, adding it the main view on the main thread

前端 未结 3 1425
我寻月下人不归
我寻月下人不归 2021-01-11 10:49

I am new to objective C, coming from .NET and java background.

So I need to create some UIwebviews asynchronously, I am doing this on my own queue using

<         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-11 11:09

    As rob said the UI changes should be done only on main thread.You are trying to add from a secondary thread.Change your code [self.view addSubview:webView]; to

    [self.view performSelectorOnMainThread:@selector(addSubview:) withObject:webView waitUntilDone:YES];

提交回复
热议问题