Comments (7)
Do you mean the initially selected option? If so, you'll want something like this:
row.selectorOptions = @[
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 1"],
[XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 2"],
[XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Option 3"],
];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 2"];
from xlform.
Thanks for your reply.
Indeed I meant the initially selected option.
I save in my backend the selected XLFormOptions value (in this case '2'). I thought I just had to set row.value = 2 to have the XLFormOptionsObject displayed and selected.
Is this the case? Do I have to set the whole XLFormOptionsObject ([XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 2"])?
Thanks
from xlform.
That's correct.
from xlform.
I guess you mean to set the whole whole XLFormOptionsObject.
It would be nice to have it as a dictionary: I give the key, it displays the text.
Thanks for this control.
from xlform.
You can avoid creating a new XLFormOptionsObject
instance by selecting a value from the row.selectorOptions
array. Like so:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"formValue == %@", @(3)];
row.value = [[row.selectorOptions filteredArrayUsingPredicate:predicate] objectAtIndex:0];
You can replace 3
with the form value of the object you want selected.
from xlform.
@batouri ,
You can get the reference to any XLFormOptionsObject
using the convenient method +(XLFormOptionsObject *)formOptionsOptionForValue:(id)value fromOptions:(NSArray *)options;
. Basically it does exactly the same @adamcooke suggests above.
Take a look at XLFormOptionsObject class definition...
@interface XLFormOptionsObject : NSObject <XLFormOptionObject>
+(XLFormOptionsObject *)formOptionsObjectWithValue:(id)value displayText:(NSString *)displayText;
+(XLFormOptionsObject *)formOptionsOptionForValue:(id)value fromOptions:(NSArray *)options;
+(XLFormOptionsObject *)formOptionsOptionForDisplayText:(NSString *)displayText fromOptions:(NSArray *)options;
@end
You can also take a look at https://github.com/xmartlabs/XLForm#selector-rows to see how to use another class as selector option. You can use some basic types, for example NSString, or any class that conforms to XLFormOptionObject
protocol (XLFormOptionsObject
conforms to it and it's just a convenience class).
from xlform.
Great! Thanks
from xlform.
Related Issues (20)
- Round corner
- Help Needed: How can I get the cell like Native iPhone Calendar's Add Event HOT 3
- CALayer bounds contains NaN: [0 nan; 320 291]
- [UIColor systemGray3Color] No known class method for selector 'systemGray3Color' HOT 3
- iOS 11 - Keyboard
- No navigation VC is not considered
- Crash: Inline date picker row following alert presentation. Attempted to scroll the table view to an out-of-bounds row
- Ability to change TextField Auto Capitalization
- Support for distribution via Swift Package Manager HOT 2
- UIDatePicker Style in iOS 14 HOT 4
- trailingSwipeActionsConfigurationForRowAtIndexPath never called
- Detected a case where constraints ambiguously suggest a height of zero for a table view cell's content view. HOT 2
- How to change the section header or change tableview style HOT 6
- How to wait the response and then update the value - need to refresh the data in time HOT 4
- Framework not found XLForm.framework
- Fields are overlapping and everything appears on first row when built from Xcode 13 and Later HOT 1
- Image adding in the form in obj C
- How to edit XLFormOptionsViewController tableviewstyle to UITableViewStyleInsetGrouped? HOT 1
- XLFormRowDescriptorTypeSelectorPickerView becomes active but no options available in iOS 17 Beta
- Not support Mac catalyst app
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xlform.