In My Application pressing the submit button i wanted to perform submit operation but i don't know how combine the textview's value with pickerview's value.if it is possible then show me code with example.
How would you like to combine the values, as a string?
If you simply want to combine them in a single string, here's an example of how you can do it:
- (IBAction)submitPressed:(id)sender {
// Load the selected row for the first component in your picker view
// If you have more than one component you may need to look up more
// Also, you may need to translate this number into something more meaningful
// such as what the selected row represents
int selectedRow = [pickerView selectedRowInComponent:0];
NSString *myString = [NSString stringWithFormat:#"%# %d",
textView.text, selectedRow];
// Do something with myString...
}
Related
This question is a bit related to one I posed previously entitled "Recognizing UIButton from a loop".
In this case, I have generated a bunch of UITextFields with a loop. When the value of one of them is changed, I'm able to recognize which textfield it was.
However, I want to then edit every textfield that was generated. Specifically, I get input from the one textfield that was edited, and I want to recalculate the other textfields based on the input and name of the recognized textfield.
How do I call for every one of the other generated, non-edited textfields to be modified?
/Vlad
Since you are already using tags, this is what viewWithTag is used for:
// Get a reference to the textfield with tag 3
UITextField *textField3 = (UITextField *)[self.view viewWithTag:3];
// Calculate your new value
float result = 4.32; // Calculate the value that you want the textfield with tag 3 to display
// Change the contents
textField3.text = [NSString stringWithFormat:#"%f", result];
store the text fields in an array, then when you want to change the value
[self.myTextFieldArray enumerateObjectsUsingBlock:^(UITextField *textField, NSUInteger idx, BOOL *stop){
if (![textField isEqual:theTextFieldThatWasEdited])
textField.text = #"whatever text you want";
}];
I'm new to the iPhone. I have four number buttons like 1,2,3,4. When I click any button the value is displayed in a textfield, but when I click two buttons only one value is displayed in textfield.
How to display in multiple values in textfield?
You can add new string value to already displayed value in your text field, for example, in following way:
UITextField *field; // <- reference to your UITextField
NSString *value = [[NSNumber numberWithInt:1] stringValue]; // <- value to add
field.text = [NSString stringWithFormat:#"%#%#", field.text, value];
I'm new to iPhone development, so my apologies if this is a ridiculous question.
I'm following a sample from a book where it creates a exchange rate UIPicker and when you select one of the entries, it displays the conversion of US dollars into whatever currency is picked.
I want the value to be updated in my label before I start changing the value from the picker.
The very first time i enter my US dollar value in the textbox and I click on the "Return" button, i want the label to update and displays its equivalent value in whatever currency is currently selected in the picker.
I have the correct code in the didSelectRow event, and that part works as long as i start spinning the picker's component wheels, so I thought I'd take that code and put it in a function which would have one parameter i.e. row and this function would then be called from didSelectRow where the row parameter would be passed and then I would:
This is the code from the didSelectRow:
float rate = [[exchangeRates objectAtIndex:row] floatValue];
float dollars = [dollarText.text floatValue];
float result = dollars * rate;
NSString *resultString = [[NSString alloc] initWithFormat:#"%.2f USD = %.2f %#", dollars, result, [countryNames objectAtIndex:row]];
resultLabel.text = resultString;
[resultString release];
Call this function when the "Did End on Exit" event for the textbox but my I'm having two problems:
What is the correct way to write the function. Whatever way I write the function, I get various errors/warnings
How do i get the currently select row of the picker, so that I can pass it to this function when the "Did End on Exit" event occurs when i click on the "Return" button.
Thanks
T.
I am not sure, I completely understood you what exactly you are trying to do here. but still I am going ahead what you can do here is:
first of all declare an class variable of type int which will store the row index whenever didSelectRow delegate method will be called, mean time create a method like:
-(void)updateLabel:(int) rowIndex
{
float rate = [[exchangeRates objectAtIndex:row] floatValue];
float dollars = [dollarText.text floatValue];
float result = dollars * rate;
NSString *resultString = [[NSString alloc] initWithFormat:#"%.2f USD = %.2f %#", dollars, result, [countryNames objectAtIndex:rowIndex]]; // here it will go rowIndex which is the row value you stored in your variable
resultLabel.text = resultString;
[resultString release];
}
and call this method when you hit return.
I hope this helps you.
~Manoj
I am doing parsing, in my parsearray having only two data number of alerts and number of events these are fine. When we are finding the value like
NSString *alertcount = [[xmlparseArray objectAtIndex:indexPath.row ]objectForKey:#"alerts"];
and assigning these string value into label
mylabel.text = [NSString stringWithFormat:#"%#", alertcount];
same for Events.
then it becomes crash. It says:
index 0 beyond out of empty Array
And these parsing I am using in #RootViewController:
UITableViewController {
}
not using custom cell. In this rootviewcontroller class we are using 7 row(these are constant) and I want to assign at row number 5 the value of alert (i.e. mylabel.text = [NSString stringWithFormat:#"%#", alertcount]) at the right position of cell number 5 same is cell number 6.
Your xmlparseArray might be empty. Check if you have any elements in the array. Pls show the code where you populate the array so that we can have a better idea of where you are going wrong
I am tying to add the values from an array to a number of text boxes in my view. it is possible for me to make it work by implementing
a1.text=[arrayName objectAtIndex:1];
Similarly i am having a1, a2, a3,... a45,... a60,... upto a99
Here "a1" is the outlet of a particular textfield. what i need is that, i have a plenty of controls on my screen. so its not possible for me to add each and every line. is there any way to add the values from the array to the corresponding textboxes.
what i need is to have a loop which will recursively add the values from the array to the textboxes. which implements the following manually written code
a1.text = [arrayName objectAtIndex:1];
a1.text = [arrayName objectAtIndex:2];
...........
a99.text = [arrayName objectAtIndex:99];
can any one help me please...
Thanks in advance,
Shibin
When you create you controls (e.g. textfields) set their tag property to a value that can later be used to determine an index for corresponding value in your array:
for (int index = startTag; index <= endTag; ++index){
UITextField* field = (UITextField*)[view viewWithTag:index]; // or [view viewWithTag:index + someValue];
field.text = [arrayName objectAtIndex:index];
}