UIProgressView in CustomCell never show when NSNotification was sent

I've got magazine app. There is UITableView which contains custom cells. In each cell is button, icon, title and hidden UIProgressView. When someone tap to button, pages (images) are starting to download. When some page is downloaded, I want to show hidden UIProgressView or update. And there's the problem. I'm using NSNotification and performSelectorOnMainThread for updating UIProgressView. But the UIProgressView doesn't show. I don't know where error is... Thx for reply!

There's some code... Creating UIProgressView:

self.progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
[self.progressView setFrame:CGRectMake(250, 200, 92, 28)];
[self.progressView setProgress:0.0];
[self.progressView setHidden:YES];
[self.cellView addSubview:self.progressView];

Posting notificaiton:

[[NSNotificationCenter defaultCenter] postNotificationName:kDownloadedIcon object:nil userInfo:dict];

Accepting notification:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iconDownloaded:) name:kDownloadedIcon object:nil];

Resend notification to main thread:

- (void)iconDownloaded:(NSNotification *)notification {
[self performSelectorOnMainThread:@selector(updateProgressBar:) withObject:notification waitUntilDone:YES];}

Update or show UIProgressView:

- (void)updateProgressBar:(NSNotification *)notification {
NSDictionary *dict = [notification userInfo];

NSLog(@"%@ %@ %@", [dict objectForKey:@"name"], self.identifier, self.progressView);

if ([[dict objectForKey:@"name"] isEqualToString:self.identifier]) {
    if (self.spinner) [spinner stopAnimating];
    self.spinner = nil;
    [self.spinner removeFromSuperview];

    [self.progressView setHidden:NO];
    self.progress++;
    NSInteger count = [[dict objectForKey:@"pages"] intValue];
    [self.progressView setProgress:self.progress/count];
}

Answers


Hurray! Thx Tim for ideas! Your "simple project" helped me to solved it. Problem was, I start for loop. In this loop I'm posting notifications. But when for starts, it blocks main thread and UI hasn't been redrawn. So I sent calling of for loop to background and everything works fine. Thx again Tim


Need Your Help

What guarantees that the overloaded non-const method is invoked?

c++ recursion signature

Given these 2 functions that modify and return a string:

Is there any Equivalent to ValidateAntiForgeryToken in ServiceStack?

c# servicestack

I'm looking at SS code in github and I can't to find any equivalent to ValidateAntiForgeryToken because I don't want to reinvent the wheel and I'd like to reuse as much as possible the SS framework...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.