so i created a weather app.
It has a text field where user types the city and then click the button.
The city name will be passed to a function that will request a data for this city.
I have passed the city name to this function
-(void)getCurrent:(NSString *)query
by this way
[theWeather getCurrent:self.TextField.text];
But now i decided to change text field to uipickerview and i got stuck
How can i pass the selected row in my picker view to this function ?
You can access your selected row by accessing the array:
You can get it in the following manner:
NSInteger row;
row = [self.pickerView selectedRowInComponent:0];
getCurrent:_pickerData[row]
Since you have a UIPickerView you can inspect its selectedRowInComponent: to determine which item the user has selected. Assuming you populated this picker view from an array you can get the item out if this array using the index returned here. Also assuming that you have a PickerView with only a list of cities pass 0 for the component. The component is there for more complex views like a time picker where you have hours, minutes, and AM/PM.
Related
I need to have a focus on the Grid View but I would like to get it by value, for example if I have a Names column and I want to get the row for the name 'Walter' I would like to get the focus for that row.
In this case, this is done by key of the row, but I need it by value.
var sender = (MVCxGridView)s;
// Set the zero-based index of the focused row.
sender.FocusedRowIndex = 6;
As i know you cannot focus with value in a gridview. When I need to do this scenario I do it this way,follow the steps bellow using asp.net:
1. For i=0 to gridview.RowCount-1
2.If gridview.getrowcellvalue(i,gridview.columns("Name")
3. gridview.FocusedRowHandle=i
End If
Next
I've a plist file named as "data.plist" like this:
I have six arrays, and I also have 6 buttons and a text field. I would like to save the string in the text field to the correct array when I press the right button.
There are many approaches, here is one:
Name the keys for the arrays in the plist dictionary livello_0 - livello_5.
Assign tags 0 - 5 to the buttons (indexes are zero-based).
When a button is pressed, get the tag (let tag = sender.tag) and get the array with let array = data["livello_\(tag)"].
Update / write the value.
If it is a Swift collection type, assign the array back to the dictionary (value semantics).
Make the changes as below.
Structure of the pList:
Make the button titles as the keys in the plist.
Logic to save:
When a button is pressed, fetch the array of the button's title and save the text from the textField into the array. Update this new array as the value for the key(selectedButton's title)
Set tag to each buttons in a pattern. eg. Button tag corresponding to 0th row of plist will be 0+1000
By doing this you will get the corresponding index of array in plist when user taps the button by doing (tag-1000)
On button tap get the string from text field and save to plist.
Note: It is necessary to set tag more than 0 because by default all the ui elements have 0 as tag.
I want to display data like this with a JSH h datatable:
1st OBJECT
object.title object.date
object.category object.description
2nd OBJECT
object.title object.date
object.category object.description
....
So I need multiple rows (2 rows) in one column.
But I have no idea how that works.
Normally, a h:dataTable displays data for every object row by row.
For example:
But Id like to display it like above but for every object. So each oh my objects must be displayed like above.
How can I solve this?
I want to get the selected item ids in a String array (preferably). How to get the selected item ids when multiple items are selected?
The documentation is often helpful :-)
You can select an item with the corresponding setValue() method. In multiselect mode, the property will be an unmodifiable set of item identifiers. If no item is selected, the property will be null in single selection mode or an empty collection in multiselect mode.
So after casting comboBox.getValue() to Set<?> you can call toArray(new String[0]) to get the desired array.
I'm using a UIPickerView, and it has the first value chosen by default. When the user doesn't move the UIPickerView from this initial selection, however, the value selected comes back as NSNull. How can I make it so either:
The first value is recognized whether the user changes the selection or not.
The UIPickerView contains a blank value that I can check for in the first spot.
You can use
[_picker selectedRowInComponent:0]
nil means no one move the picker (you can make the first item blank or sth like "--" )
Reference : https://stackoverflow.com/a/27058363/471840