以编程方式创建的 activity 指标未删除
Programmatically created activity indicator not removing
我想在 UIButton
上添加一个 ActivityIndicator
所以我这样做了
-(IBAction)SetNationality:(id)sender
{
actInd=[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[btnpost addSubview:actInd];
[actInd startAnimating];
NSMutableDictionary *dictionaly=[[NSMutableDictionary alloc] init];
[dictionaly setValue:[NSNumber numberWithInt:0] forKey:@"NationalityCode"];
[dictionaly setValue:@"nationalitytest test" forKey:@"NationalityName"];
[dictionaly setValue:[NSNumber numberWithInt:0] forKey:@"Deleted"];
[dictionaly setValue:[NSNumber numberWithInt:1] forKey:@"Status"];
NSMutableDictionary *dictNationality=[[NSMutableDictionary alloc] init];
[dictNationality setObject:dictionaly forKey:@"Nationality"];
[wb prepareURL:@"ProfileConfig/Nationalities" :@"" :YES :NO :dictNationality:^(NSString *status)
{
[self DataReceived];
}];
}
然后我删除了这个方法中的 activity 指示器
-(void)DataReceived
{
[actInd removeFromSuperview];
NSLog(@"data array %@",dm.arrayData);
}
但我的问题是 activity指标没有从超级视图中删除。它一直在旋转。我怎么解决这个问题。
谢谢
试试这个代码:
-(void)DataReceived
{
dispatch_async(dispatch_get_main_queue(), ^{
[actInd stopAnimating];
[actInd removeFromSuperview];
// do your UI updates here...
});
NSLog(@"data array %@",dm.arrayData);
}
无需从父视图中删除 activity 指示器。
只需停止 activity 指示器动画即可。
-(void)DataReceived
{
dispatch_async(dispatch_get_main_queue(), ^{
[actInd stopAnimating];
});
}
希望对您有所帮助:
- (void) hideActivityIndicator {
actInd.hidden = YES;
[UIView animateWithDuration:0.3 animations:^{
actInd.alpha = 0.0;
} completion:^(BOOL finished) {
[actInd stopAnimating];
}];
}
我想在 UIButton
上添加一个 ActivityIndicator
所以我这样做了
-(IBAction)SetNationality:(id)sender
{
actInd=[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[btnpost addSubview:actInd];
[actInd startAnimating];
NSMutableDictionary *dictionaly=[[NSMutableDictionary alloc] init];
[dictionaly setValue:[NSNumber numberWithInt:0] forKey:@"NationalityCode"];
[dictionaly setValue:@"nationalitytest test" forKey:@"NationalityName"];
[dictionaly setValue:[NSNumber numberWithInt:0] forKey:@"Deleted"];
[dictionaly setValue:[NSNumber numberWithInt:1] forKey:@"Status"];
NSMutableDictionary *dictNationality=[[NSMutableDictionary alloc] init];
[dictNationality setObject:dictionaly forKey:@"Nationality"];
[wb prepareURL:@"ProfileConfig/Nationalities" :@"" :YES :NO :dictNationality:^(NSString *status)
{
[self DataReceived];
}];
}
然后我删除了这个方法中的 activity 指示器
-(void)DataReceived
{
[actInd removeFromSuperview];
NSLog(@"data array %@",dm.arrayData);
}
但我的问题是 activity指标没有从超级视图中删除。它一直在旋转。我怎么解决这个问题。 谢谢
试试这个代码:
-(void)DataReceived
{
dispatch_async(dispatch_get_main_queue(), ^{
[actInd stopAnimating];
[actInd removeFromSuperview];
// do your UI updates here...
});
NSLog(@"data array %@",dm.arrayData);
}
无需从父视图中删除 activity 指示器。 只需停止 activity 指示器动画即可。
-(void)DataReceived
{
dispatch_async(dispatch_get_main_queue(), ^{
[actInd stopAnimating];
});
}
希望对您有所帮助:
- (void) hideActivityIndicator {
actInd.hidden = YES;
[UIView animateWithDuration:0.3 animations:^{
actInd.alpha = 0.0;
} completion:^(BOOL finished) {
[actInd stopAnimating];
}];
}