Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close
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]; }); |
Be the first to comment.