uitableview - iOS Adding Image to Tableview Background View -


i have tableview using display data loaded web service. loads fast, other times take awhile. while it's loading, tableview shows blank screen (in case gray screen). want display in tableview background view simple image says loading , has loading icon animate spin, cannot show @ all. here code:

uiview *backgroundview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 320, self.view.bounds.size.height)]; [backgroundview setbackgroundcolor:[uicolor colorwithred:227.0 / 255.0 green:227.0 / 255.0 blue:227.0 / 255.0 alpha:1.0]];  self.tableloading.image = [uiimage imagenamed:@"loading.png"]; self.tableloading.frame = cgrectmake(145, 80, 30, 30); [backgroundview addsubview:self.tableloading];  [self.feedtableview setbackgroundview:backgroundview]; 

the background view shows expected, hence gray background, cannot image show @ all.

any suggestions? seems simple problem have spent long time @ no success. in advance!

you can avoid using uiview , instead can use activity indicator. try this:

-(void)viewdidload{     uiview *backgroundview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 320, self.view.bounds.size.height)];     backgroundview.tag=1;     [backgroundview setbackgroundcolor:[uicolor colorwithred:227.0 / 255.0 green:227.0 / 255.0 blue:227.0 / 255.0 alpha:1.0]];      self.tableloading.image = [uiimage imagenamed:@"loading.png"];     self.tableloading.frame = cgrectmake(145, 80, 30, 30);      [backgroundview addsubview:self.tableloading];     [self.view addsubview:backgroundview];     dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{     // web service call asynchronous         dispatch_sync(dispatch_get_main_queue(), ^{             //all ui needs here, in thread             // remove superview loading image show tableview content             (uiview *subview in [self.view subviews]) {                 if (subview.tag == 1) {                     [subview removefromsuperview];                 }             }             [self.yourtableview reloaddata];         });     }); } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -