uitableview - Managing UIPickerView datasource between a UIVIewController, a custom UITableViewCell and a Utility Class -


I have a custom UITableViewCell class that includes a PIC cell and its contents are populated by the data data unit. Since this custom cell can be viewed in more than one view controller, I have a utility class that I want to handle in construction, data source and representative methods.

I think that when I set myself a data source, the cell displays something correctly. When I set it to the utility class, only the numberOfComponentsInPickerView: method is called and after that the app does nothing in the log (lldb) logs. For my code sample, I am going to create a simple picker with the title "Component" with one component and one line.

  ViewController.m - (UITableViewCell *) TableView: (UITableView *) TableView CellForUreActApp Path: (NSINXPath *) IndexPath {PickerCell * pCell = Zero; Picker * picker = [self. Ore objectItindex: indexpath.ro]; UtilityCustomCells * Cellulitity = [[Utility Customs CLLO] INS]; PCell = [Create cellulitePicker cell: user with table view: kPickerCellRID and picture: picker]; PCell.picker.delegate = cellUtility; // pCell.picker.dataSource = cellUtility does not work; // does not work / * it pCell.picker.delegate = self; PCell.picker.dataSource = self; * / Return PCL; }}   

and

  UtilityGuoved Cells.h #import "PickerCell.h" #import "Picker.h" @protocolCustomCellIntensive & lt; NSObject, UIPickerViewDataSource, UIPickerViewDelegate & gt; - (NSInteger) numberOfComponentsInPickerView: (UIPickerView *) pickerView; - (NSInteger) PickView: (UIPickerView *) PickerView numberoffrose engine: (NSINtegger) component; - (NSString *) PickView: (UIPickerView *) PickView Title Forrero: (NSInteger) Component for line: (NSInteger) component; @end   

Finally:

  UtilityCustomCells.m - (NSInteger) pickerView: (UIPickerView *) PickViewViewOfroject Incorporated: (NSInteger) Component {NSLog (@ "Here1"); Return 1; } - (NSInteger) numberOfComponentsInPickerView: (UIPickerView *) pickerView {NSLog (@ "here2"); Return 1; } - (NSString *) pickerView: (UIPickerView *) PickerView Title: For the NSInteger command: NSInteger component {NSLog (@ "here3"); NSSTING * title = @ "Test"; Return title; }   

To simply repeat, only the "here2" log is printed. Any advice would be much appreciated. thank you in advanced!

I was able to figure out I UtilitiesCustomCell class cellForRowAtIndexPath Immediately providing the dataset method in ViewController.m in . In fact, I needed to make it an example variable of alloc / init in ViewController.m and viewDidLoad . So now:

  viewtransfer.m @ interface assetsforvc () {utility consultancy * celluli; } @end - (zero) viewDidoadload [[Super Viewedload]; Cellulitity = [[Utility customs CLLO] INS]; Cellulitity. PickerDataSource = [Self-configured PictureData]; } - (UITableViewCell *) TableView: (UITableView *) Table View CellForAind Pound: (NSIndexPath *) Index Path {PickerCell * pCell = Zero; Picker * picker = [self. Ore objectItindex: indexpath.ro]; PCell = [Create cellulitePicker cell: user with table view: kPickerCellRID and picture: picker]; PCell.picker.delegate = cellUtility; PCell.picker.dataSource = Cell Feature; Return PCL; }}   

I now have the dictionary reader data source from UtilityCustomCells.h

for cellulite through a property I can send. @property (non-standard, strong) NSDRIGES * PickerDataSource;

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -