Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass a UIscrollview to be used by delegate class
    primarykey
    data
    text
    <p>I am not new to delegates but I AM new to the syntax to create a delegate in its own class.</p> <p>Essentially I have a PickerView delegate that I have created in its own class. I want to be able to put the selection text into a textbox in a UIScrollView that has been declared in my ViewController. However I don't know the syntax to show the delegate the view. Here are the .h and .m files of the delegate. If there are any other missing components I need to have my ViewController see my delegate that I do not have, please let me know as well. The error is in the didSelectRow method.</p> <p>RadioPickerDelegate.h</p> <pre><code> #import &lt;Foundation/Foundation.h&gt; @class MissionInputViewController; @interface RadioPickerDelegate : NSObject&lt;UITextFieldDelegate&gt;{ NSArray *radioOptions; } @property (nonatomic, retain) NSArray *radioOptions; @end </code></pre> <p>RadioPickerDelegate.M</p> <pre><code>#import "RadioPickerDelegate.h" #import "MissionInputViewController.h" @implementation RadioPickerDelegate @synthesize radioOptions; - (void)pickerView:(UIPickerView *)pickerView didSelectRow: (NSInteger)row inComponent:(NSInteger)component { // Handle the selection UITextField *textField = (UITextField *)[inputsView viewWithTag:pickerView.tag]; textField.text = [radioOptions objectAtIndex:row]; //The error is at the inputsView value. That is my UIScrollView from the view controller } // tell the picker how many rows are available for a given component - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return 2; } // tell the picker how many components it will have - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } // tell the picker the title for a given component - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { radioOptions = [[NSArray alloc] initWithObjects: @"Yes", @"No"]; return [radioOptions objectAtIndex:row]; } // tell the picker the width of each row for a given component - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { int sectionWidth = 200; return sectionWidth; } @end </code></pre> <p>Basically I want to create a PickerView in my ViewController and have it use this delegate. Then this delegate must update a textfield in a UIScrollView in my ViewController. I need to somehow have this delegate see/use that UIScrollView(inputsView). </p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload