1
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSString *country=[[NSUserDefaults standardUserDefaults]objectForKey:@"namecountry"];
//url's
NSURL *url = [NSURL URLWithString:@"someurl"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:country forKey:@"c_name"];
[request setRequestMethod:@"POST"];
[request setValidatesSecureCertificate:NO];
[request setDelegate:self];
[request startSynchronous];
NSString *response = [request responseString];
NSLog(@"%@",response);
res=[[response componentsSeparatedByString:@","] retain];
NSLog(@"%@",[res objectAtIndex:18]);
show=[NSString stringWithFormat:@"%@",[res objectAtIndex:18]];
float f=[show floatValue];
show=[NSString stringWithFormat:@"%.2f %%",f];
[show retain];
}
これは情報を表示する2番目のタブです。しかし、私はそれをクリックしたときに時々ランダムな推測を更新しません。私はそれが毎回更新したいと思います。 [self.tableView reloadData];私がタブバーのアイコンをクリックすると、そのメソッドを呼び出すことがわかるので、書き直す必要はありません。この関数は、私のviewDidAppearです。 Nslogログは更新された値を提供して、なぜ表のセルを更新しないのかを示します。tableviewcellが更新されないのはなぜですか?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if (indexPath.row % 2 == 0) {
// EVEN
cell = [tableView dequeueReusableCellWithIdentifier:@"EvenCell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"EvenCell"] autorelease];
UIView *bg = [[UIView alloc] initWithFrame:cell.frame];
UIColor *colour = [[UIColor alloc] initWithRed: (208.0/255.f) green: (231.0/255.f)
blue: (241.0/255.f) alpha: 1.0];
bg.backgroundColor = colour;
cell.backgroundView = bg;
cell.textLabel.backgroundColor = bg.backgroundColor;
[bg release];
cell.detailTextLabel.backgroundColor=[UIColor clearColor];
cell.detailTextLabel.text=show;
}
cell.textLabel.text = [array objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
} else {
// ODD
cell = [tableView dequeueReusableCellWithIdentifier:@"OddCell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"OddCell"] autorelease];
UIView *bg = [[UIView alloc] initWithFrame:cell.frame];
UIColor *colour = [[UIColor alloc] initWithRed: (143.0/255.f) green: (169.0/255.f)
blue: (180.0/255.f) alpha: 1.0];
bg.backgroundColor = colour;
cell.backgroundView = bg;
cell.textLabel.backgroundColor = bg.backgroundColor;
[bg release];
}
cell.textLabel.text = [array objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
この1つは私がcell.detailTextLabel.text =ショーを書く細胞を作成する機能です。それは更新値を表示することができますが、私はそれがランダムに更新されているかどうかは誰にも分かりませんでした。 btw私は奇妙な細胞を使用しないでください。ただのコンセプトです。
ユーザーがタブバーで選択するたびに更新されない理由を確認していただきありがとうございますか? –
彼らは正しいです値はcellforrowatindexpathに来て右 –
場合は、コードに何も問題はありません。あなたは問題のためにあなたのアプリの他の場所をチェックする必要があります。 – memmons