我试图从服务器加载数据时更新UIProgressview。我有一个具有sharedInstance的类来处理服务器通信,并且有一种从服务器获取数据的方法(在while循环中)。现在我想通过从我的server-communication-Class(sharedInstance)发送通知来更新我的UIProgressView,并且它根本不起作用。更新带有通知的UIProgressView
在InterfaceBuilder中正确设置了UIProgressView并且show/hide/setProgress工作正常,但setProgress无法通过通知工作。
下面是测试循环在我的服务器通信类:
- (void)completeServerQueue {
NSNumber *progress = [[NSNumber alloc] init];
for (int i=0; i<15; i++) {
progress = [[NSNumber alloc] initWithFloat:(100/15*i) ];
float test = [progress floatValue];
[[NSNotificationCenter defaultCenter]
postNotificationName:@"ServerQueueProgress"
object:progress];
sleep(1);
}
}
而且这是在检测到通知时调用的方法(我用的断点检查了它,它是执行...):
- (void)serverQueueProgress:(NSNotification *)notification {
[serverQueueProgressView setProgress:[[notification object] floatValue]];
}
任何想法?