Updated 14 December 2016
When you are creating UIVIEW dynamically without using the storyboard then sometimes your app gets in background thread. And your application gets stuck for a few seconds to resolve this put your code in the main thread. So that your uiview run in the main thread. It will not effect the background tasks that are already running.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
dispatch_async(dispatch_get_main_queue(), ^{ //your code here..... UIView *ordersDetailsBlock = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, height)]; [ordersDetailsBlock setBackgroundColor : [UIColor whiteColor]]; ordersDetailsBlock.layer.cornerRadius = 4; [self.view addSubview:ordersDetailsBlock]; UILabel *summaryInfLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, SCREEN_WIDTH-4, 24)]; [summaryInfLabel setTextColor:[UIColor blackColor]]; [summaryInfLabel setFont:[UIFont fontWithName: @"Trebuchet MS" size: 20.0f]]; NSString *summaryInfLabelText = [NSString stringWithFormat:@"Summary"]; [summaryInfLabel setText:summaryInfLabelText]; [ordersDetailsBlock addSubview:summaryInfLabel]; }); |
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.