@interface NavigationController : UITableViewController
が私のテーブルビューは、ユーザーがタブバーをクリックしたときにprogramaticlyので、底部file.At何XIBは私がテーブルを更新していない作成されたテーブルビューの更新、それを自己。これが私がviewDidAppearに入れた理由です。しかし、テーブルは毎回更新されるのではなく、ただランダムに更新されます。テーブルに書き込まれたショーの値を見ることができます。nslogは正しい値を書き込みますが、テーブルは常に正しい値を表示しませんでした。 ?ランダム
- (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]] retain];
float f=[show floatValue];
show=[NSString stringWithFormat:@"%.2f %%",f];
}
編集::
- (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];
show=[[NSString stringWithFormat:@"%@",[res objectAtIndex:18]] retain];
float f=[show floatValue];
show=[NSString stringWithFormat:@"%.2f %%",f];
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;
}
テーブルをリロードしましたか?表は何を示していますか? – iOS
私は[self.tableView reloadData]を使用します。それは同じ値が更新されていない値を示していますが、私はプログラムを閉じてそれを開始すると正しい値を示します –
テーブルをリロードする部分を私に見せてもらえますか? – iOS