iphone - Cannot get UIActivityIndicatorView to show while loading data -


i have uiactivityindicatorview on tableviewcontroller. when start animating in init see activity indicator, when move start command anywhere else not work/show. have idea doing wrong, cannot seem find on here. want show while loading data.

tableviewcontroller.h

#import <uikit/uikit.h>   @interface categorytableviewcontroller : uitableviewcontroller {     nsarray *cats;     uiactivityindicatorview *activityindicator; }  @end 

tableviewcontroller.m

#import "categorytableviewcontroller.h" #import "nieuwsdatamanager.h" #import "categorytablecell.h" #import "niewscategory.h" #import "nieuwstableviewcontroller.h"   @implementation categorytableviewcontroller  - (id)initwithstyle:(uitableviewstyle)style {     self = [super initwithstyle:style];     if (self) {         cats = [[nsarray alloc ] initwitharray:[nieuwsdatamanager sharedinstance].newscategories];         self.title = @"nieuws" ;         activityindicator = [[uiactivityindicatorview alloc] initwithframe: cgrectmake(100,150,120,120)];         activityindicator.activityindicatorviewstyle = uiactivityindicatorviewstylegray;           [self.view addsubview:activityindicator];       }     return self; }  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {      [activityindicator startanimating];        niewscategory *cat = [[nieuwsdatamanager sharedinstance].newsdata objectforkey:[cats objectatindex:indexpath.row]];        [[nieuwsdatamanager sharedinstance] getnewsbycategory:cat];        nieuwstableviewcontroller *nt = [[nieuwstableviewcontroller alloc] initwithcategory:cat];      [activityindicator stopanimating];      [self.navigationcontroller pushviewcontroller:nt animated:yes];      [nt release];      [self.tableview deselectrowatindexpath:indexpath animated:no]; } 

i have noticed in past uiactivityindicators draw while ui thread hung, may possible need perform task in background thread in order ui thread animate progress indicator. see apple's documentation concurrency programming. in general perform lengthy operations on background thread ui thread can remain responsive user.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -