diff --git a/contrib/mobile/iOS/Onelab/MasterViewController.mm b/contrib/mobile/iOS/Onelab/MasterViewController.mm index 743db7c9bcd2827bd6ed9564aaa89e0c5150d3e2..b77e757fec91128ed0322a19ff5c158d4bd3e906 100644 --- a/contrib/mobile/iOS/Onelab/MasterViewController.mm +++ b/contrib/mobile/iOS/Onelab/MasterViewController.mm @@ -97,6 +97,8 @@ NSMutableArray *section = [_sections objectAtIndex:j]; for(int k=0; k<[section count];k++) if([[[section objectAtIndex: k] getName] isEqualToString:name]) { + parameter * p = [section objectAtIndex: k]; + [p refresh]; found = true; break; } @@ -131,8 +133,8 @@ NSMutableArray *section = [_sections objectAtIndex:j]; for(int k=0; k<[section count];k++) if([[(parameter*)[section objectAtIndex: k] getName] isEqualToString:name]) { - parameterStringList * p = (parameterStringList *)[section objectAtIndex: k]; - [p reload]; + parameter * p = [section objectAtIndex: k]; + [p refresh]; found = true; break; } // the parameters is already in the section @@ -157,9 +159,9 @@ // Release any retained subviews of the main view. } -- (void)viewDidAppear:(BOOL)animated +- (void)viewWillAppear:(BOOL)animated { - [super viewDidAppear:animated]; + [super viewWillAppear:animated]; [self getAvailableParam]; [self.tableView reloadData]; } @@ -171,7 +173,7 @@ - (void)refreshParameters:(id)sender { [self getAvailableParam]; // Get the param - [self.tableView reloadData]; + [self.tableView reloadData]; } - (void)resetParameters:(id)sender { @@ -180,7 +182,7 @@ [_sectionstitle removeAllObjects]; [self.tableView reloadData]; [self getAvailableParam]; // Get the param - [self.tableView reloadData]; + [self.tableView reloadData]; onelab_cb("check"); [[NSNotificationCenter defaultCenter] postNotificationName:@"requestRender" object:nil]; } @@ -235,12 +237,15 @@ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // get the param with his name + static NSString *CellIdentifier = @"parameterCell"; + if(indexPath.section >= _sections.count) return [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; NSMutableArray *sectionContent = [_sections objectAtIndex:[indexPath section]]; + if(indexPath.row >= sectionContent.count) return [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; parameter *tmp = [sectionContent objectAtIndex:[indexPath row]]; UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if(cell == nil) - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[[tmp getLabel] text]]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; else return cell; [cell setUserInteractionEnabled:!([tmp isReadOnly])]; diff --git a/contrib/mobile/iOS/Onelab/parameter.mm b/contrib/mobile/iOS/Onelab/parameter.mm index 961adc30c6def136322c69ff7f8d1ba32b65b345..79e3bfa60cfe115e3d3e108c61292ffc4e5b7cb5 100644 --- a/contrib/mobile/iOS/Onelab/parameter.mm +++ b/contrib/mobile/iOS/Onelab/parameter.mm @@ -56,7 +56,7 @@ if(self) { label.alpha = (string.getReadOnly())? 0.439216f : 1.0f; - [label setText:[NSString stringWithCString:(string.getLabel() != "")?string.getLabel().c_str():string.getName().c_str() encoding:[NSString defaultCStringEncoding]]]; + [label setText:(string.getLabel() != "")?[NSString stringWithCString:string.getLabel().c_str() encoding:[NSString defaultCStringEncoding]] : [[[NSString stringWithCString:string.getName().c_str() encoding:[NSString defaultCStringEncoding]] componentsSeparatedByString:@"/"] lastObject]]; name = [NSString stringWithCString:string.getName().c_str() encoding:[NSString defaultCStringEncoding]]; picker = [[UIPickerView alloc] init]; picker.showsSelectionIndicator = YES; @@ -138,7 +138,7 @@ if(self) { label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; - [label setText:[NSString stringWithCString:(number.getLabel() != "")?number.getLabel().c_str():number.getName().c_str() encoding:[NSString defaultCStringEncoding]]]; + [label setText:(number.getLabel() != "")?[NSString stringWithCString:number.getLabel().c_str() encoding:[NSString defaultCStringEncoding]] : [[[NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]] componentsSeparatedByString:@"/"] lastObject]]; name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]]; picker = [[UIPickerView alloc] init]; picker.showsSelectionIndicator = YES; @@ -210,7 +210,7 @@ if(self) { label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; - [label setText:[NSString stringWithCString:(number.getLabel() != "")?number.getLabel().c_str():number.getName().c_str() encoding:[NSString defaultCStringEncoding]]]; + [label setText:(number.getLabel() != "")?[NSString stringWithCString:number.getLabel().c_str() encoding:[NSString defaultCStringEncoding]] : [[[NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]] componentsSeparatedByString:@"/"] lastObject]]; name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]]; checkbox = [[UISwitch alloc] init]; [checkbox setSelected:(number.getValue() == 1)]; @@ -270,7 +270,7 @@ //TODO add step ? [slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventTouchUpOutside]; [slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventTouchUpInside]; - [label setText:[NSString stringWithFormat:@"%@ %f" ,[NSString stringWithCString:(number.getLabel() != "")?number.getLabel().c_str():number.getName().c_str() encoding:[NSString defaultCStringEncoding]], number.getValue()]]; + [label setText:[NSString stringWithFormat:@"%@ %f" ,(number.getLabel() != "")?[NSString stringWithCString:number.getLabel().c_str() encoding:[NSString defaultCStringEncoding]] : [[[NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]] componentsSeparatedByString:@"/"] lastObject], number.getValue()]]; } return self; } @@ -322,7 +322,7 @@ if(self) { label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; - [label setText:[NSString stringWithCString:(number.getLabel() != "")?number.getLabel().c_str():number.getName().c_str() encoding:[NSString defaultCStringEncoding]]]; + [label setText:(number.getLabel() != "")?[NSString stringWithCString:number.getLabel().c_str() encoding:[NSString defaultCStringEncoding]] : [[[NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]] componentsSeparatedByString:@"/"] lastObject]]; name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]]; textbox = [[UITextField alloc] init]; [textbox setBorderStyle:UITextBorderStyleRoundedRect]; @@ -346,6 +346,7 @@ onelab::server::instance()->get(number,[name UTF8String]); if(number.size() < 1) return; [textbox setText:[NSString stringWithFormat:@"%f", number[0].getValue()]]; + [textbox reloadInputViews]; } -(BOOL)textFieldShouldEndEditing:(UITextField *)textField {