removeFromSuperview doesn't work

后端 未结 3 1111
灰色年华
灰色年华 2021-02-20 01:29

I need to be able to remove a button from a view and add a different one. My code looks like this:

-(void)UpdatePromoBanner:(NSString*)value{
    [button setTitl         


        
3条回答
  •  轮回少年
    2021-02-20 01:42

    Oscar is right. You have to update the interface on the main thread. Figured I'd add in some code to help.

    Replace:

    [subView removeFromSuperview];
    

    With:

    [subView performSelectorOnMainThread:@selector(removeFromSuperview) withObject:nil waitUntilDone:NO];
    

    And I think you should be good to go without changing anything else.

提交回复
热议问题