0
每次這個標籤被加載而不是更新動態標籤,它會在它上面寫一個全新的標籤。我需要在代碼中添加什麼,以便更新它或清除動態標籤,然後放入新標籤。我覺得它可能只是一個簡單的一行修復。下面是代碼的簡化版本:ios正確的方式來更新與viewdidarar programatic uilabels
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:YES];
goalArray = [[NSMutableArray alloc] init];
NSURL *url = [NSURL URLWithString:@"http://localhost/goal.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:test forKey:@"name"];
[request setDelegate:self];
[request startAsynchronous];
}
- (void)requestFinished:(ASIFormDataRequest *)request
{
...
for (id myArrayElement in goalArray)
{
NSLog(@"y value:%i", yValue);
UILabel *label = [[UILabel alloc] initWithFrame: CGRectMake(0, yValue, 80, 44)];
label.font = [UIFont systemFontOfSize:12];
label.textColor = [UIColor blackColor];
label.backgroundColor = [UIColor clearColor];
label.text = myArrayElement;
[self.view addSubview:label];
yValue += 44;
}
}
如果你想投票評論會很好 – user1108720 2012-01-28 01:56:59