Skip to content
Snippets Groups Projects
Commit a875509b authored by Maxime Graulich's avatar Maxime Graulich
Browse files

refresh parameters value on iOS

parent e32af1fe
No related branches found
No related tags found
No related merge requests found
...@@ -97,6 +97,8 @@ ...@@ -97,6 +97,8 @@
NSMutableArray *section = [_sections objectAtIndex:j]; NSMutableArray *section = [_sections objectAtIndex:j];
for(int k=0; k<[section count];k++) for(int k=0; k<[section count];k++)
if([[[section objectAtIndex: k] getName] isEqualToString:name]) { if([[[section objectAtIndex: k] getName] isEqualToString:name]) {
parameter * p = [section objectAtIndex: k];
[p refresh];
found = true; found = true;
break; break;
} }
...@@ -131,8 +133,8 @@ ...@@ -131,8 +133,8 @@
NSMutableArray *section = [_sections objectAtIndex:j]; NSMutableArray *section = [_sections objectAtIndex:j];
for(int k=0; k<[section count];k++) for(int k=0; k<[section count];k++)
if([[(parameter*)[section objectAtIndex: k] getName] isEqualToString:name]) { if([[(parameter*)[section objectAtIndex: k] getName] isEqualToString:name]) {
parameterStringList * p = (parameterStringList *)[section objectAtIndex: k]; parameter * p = [section objectAtIndex: k];
[p reload]; [p refresh];
found = true; found = true;
break; break;
} // the parameters is already in the section } // the parameters is already in the section
...@@ -157,9 +159,9 @@ ...@@ -157,9 +159,9 @@
// Release any retained subviews of the main view. // 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 getAvailableParam];
[self.tableView reloadData]; [self.tableView reloadData];
} }
...@@ -235,12 +237,15 @@ ...@@ -235,12 +237,15 @@
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
// get the param with his name // 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]]; NSMutableArray *sectionContent = [_sections objectAtIndex:[indexPath section]];
if(indexPath.row >= sectionContent.count) return [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
parameter *tmp = [sectionContent objectAtIndex:[indexPath row]]; parameter *tmp = [sectionContent objectAtIndex:[indexPath row]];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if(cell == nil) if(cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[[tmp getLabel] text]]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
else else
return cell; return cell;
[cell setUserInteractionEnabled:!([tmp isReadOnly])]; [cell setUserInteractionEnabled:!([tmp isReadOnly])];
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
if(self) if(self)
{ {
label.alpha = (string.getReadOnly())? 0.439216f : 1.0f; 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]]; name = [NSString stringWithCString:string.getName().c_str() encoding:[NSString defaultCStringEncoding]];
picker = [[UIPickerView alloc] init]; picker = [[UIPickerView alloc] init];
picker.showsSelectionIndicator = YES; picker.showsSelectionIndicator = YES;
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
if(self) if(self)
{ {
label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; 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]]; name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]];
picker = [[UIPickerView alloc] init]; picker = [[UIPickerView alloc] init];
picker.showsSelectionIndicator = YES; picker.showsSelectionIndicator = YES;
...@@ -210,7 +210,7 @@ ...@@ -210,7 +210,7 @@
if(self) if(self)
{ {
label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; 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]]; name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]];
checkbox = [[UISwitch alloc] init]; checkbox = [[UISwitch alloc] init];
[checkbox setSelected:(number.getValue() == 1)]; [checkbox setSelected:(number.getValue() == 1)];
...@@ -270,7 +270,7 @@ ...@@ -270,7 +270,7 @@
//TODO add step ? //TODO add step ?
[slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventTouchUpOutside]; [slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventTouchUpOutside];
[slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventTouchUpInside]; [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; return self;
} }
...@@ -322,7 +322,7 @@ ...@@ -322,7 +322,7 @@
if(self) if(self)
{ {
label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; 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]]; name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]];
textbox = [[UITextField alloc] init]; textbox = [[UITextField alloc] init];
[textbox setBorderStyle:UITextBorderStyleRoundedRect]; [textbox setBorderStyle:UITextBorderStyleRoundedRect];
...@@ -346,6 +346,7 @@ ...@@ -346,6 +346,7 @@
onelab::server::instance()->get(number,[name UTF8String]); onelab::server::instance()->get(number,[name UTF8String]);
if(number.size() < 1) return; if(number.size() < 1) return;
[textbox setText:[NSString stringWithFormat:@"%f", number[0].getValue()]]; [textbox setText:[NSString stringWithFormat:@"%f", number[0].getValue()]];
[textbox reloadInputViews];
} }
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField -(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment