ios - Not able to populate PickerView with my string -
When text field is clicked, I am using inputview to display a pickerView. Then I want to populate the preview with the numbers 1-100. I have some code that I thought would work, but when I program will click on will drive and TextField, so it should know just an empty Pikariwu will pop up way of putting a button on Further toolbar. I want to put a submit button on the right side to confirm the selection of users (being changed to cancel). Do I have to do something in the interface builder with the picker and button? Because I do not really have the interface builder because they are with the code ...
Below are my .h and .m files
h ----
@interface TestinputviewViewController: UIViewController & LT; UITextFieldDelegate, UIPickerViewDataSource, UIPickerViewDelegate & gt; {IBOutlet UITextField * textField; NSMutableArray * pickerViewArray; } - (IBAction) textFieldDidBeginEditing; @end m ---
#import "TestinputviewViewController.h" @implementation TestinputviewViewController - (IBAction) textFieldDidBeginEditing {UIPickerView * myPickerView = [[Uaipikr Viol Eloc] IITs; TextField.inputView = myPickerView; MyPickerView.showsSelectionIndicator = Yes; MyPickerView.delegate = self; MyPickerView.dataSource = self; [MyPickerView release]; UIToolbar * myToolbar = [[Uitoolbar alloc] initWithFrame: CGRectMake (0,0,320,44)]; UIBarButtonItem * donebutton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone goal: self action: @selector (inputAccessoryViewDidFinish)]; [MyToolbar set ITEMS: [Object with NSAR array: Animated button]; No;]; TextField.inputAccessoryView = myToolbar; } - (NSInteger) numberOfComponentsInPickerView: (UIPickerView *) myPickerView {return1; } - (NSInteger) pickerView: (UIPickerView *) myPickerView numberOfRowsInComponent: (NSInteger) component {return [pickerViewArray count]; } - (NSString *) pikerView: (UIPickerView *) myPickerView titleForRow: (NSInteger) line forComponent: (NSInteger) component {return [pickerViewArray objectAtIndex: line]; } // Implement ViewDidLoad to perform additional setup after loading the view, usually from a nib. - (zero) viewDidoadload [[Super Viewedload]; PickerViewArray = [[NSMutableArray alloc] init]; For (int i = 1; i & lt; = 20; i ++) {NSString * myString = [NSString stringWithFormat: @ "% d%", i]; [Picker object: mystring]; }}
You are not setting picker's representative in the current object class.
Access
`myPickerView.delegate = self;` `myPickerView.dataSource = self;` picker visual object allocation after.
Let's go ..
Comments
Post a Comment