Tuesday, 15 March 2011

ios - UITableViews and UITableViewCells -


I'm not sure what I'm doing, but if someone can tell me in the right direction, I would appreciate it I am I am creating an app in the encoder I currently have two buttons that are both views controlled by the same class to see different view controllers. There are different ideas defined in the class. I have two arrays for each scene, which is a population with information that I want to show in the scene. Here is the code from viewcontrollers .m file if I remove the breakpoint which displays both the button function, but the second button shows information from the wrong ore but goes to the right view controller. I'm completely stumped.

  #import "Tectvvievkantrolrkh" #import "Mantinstrktvievkantrolrkh" #import Tectvvievkantrolr @intrfaes "Sowatectipsvievkantrolrkh" () @and @implimenteshn Tectvvievkantrolr {nursery creation * Mantinstrkt; NSArray * techTips; } @ Synthesis table view; @ Synthesis techtable view; - (zero) viewDidoadload [[Super Viewedload]; // Getting started table data maintInstrct = [NSArray arrayWithObjects: @ "one", @ "two", zero]; Tektips = [NSARRAOD Object: @ "Three", @ "Four", Nil]; } - (zero) viewDidUutup {[SuperWooddownload]; // release any maintained subview of the main scene} - (BOOL) must be atorotettoetterface orientation: (UINPreference Orientation) Interface Orientation {Return (Interface Orientation! = UINTERFERSHAREMENT PORTATIZINGSIDEDOWN); } - (NSInteger) techTableView: (UITableView *) techTableView numberOfRowsInSection: (NSInteger) section {return [countdown count]; } - (UITableViewCell *) techTableView: (UITableView *) techTableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {static NSString * simpleTechTableIdentifier = @ "TechTipsCell"; UITableViewCell * cell = [techTableView dequeueReusableCellWithIdentifier: simpleTechTableIdentifier]; If (cell == zero) {cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: simpleTechTableIdentifier]; } Cell.textLabel.text = [Tectips objectAntx: indexpath.ro]; Return cell; } - (NSInteger) TableView: (UITableView *) table view numberofrose insignia: (NSInteger) section {return [maintInstrct count]; } - (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {static NSString * simpleTableIdentifier = @ "MaintInstrctCell"; UITableViewCell * cell = [TablesView decomputer reusableWelcome Identifier: SimpleTable Identifier]; If (cell == blue) {cell = [[Uaitibl wee Aelel] Initvith Style: Uaitiblwussel style default Riug Idiattrfir: Srlteblaidentifayr]; } Cell.textLabel.text = [maintInstrct objectAtIndex: indexPath.row]; Return cell; } - (void) prepareForSegue: (UIStoryboardSegue *) segue this: (id) This {if ([isEqualToString segue.identifier: @ "showMaintKitInstrct"]) {NSIndexPath * indexPath = [self.tableView indexPathForSelectedRow]; MaintInstrctViewController * destViewController = segue.destinationViewController; DestViewController.maintKitName = [maintInstrct objectAtIndex: indexPath.row]; } Else if ([Isekualtostring Segua.aidentifayr: @ "Sowatectips"]) {Nsindekspat * Indekspat = [Selfktctblaviav Indekspathforslektedro]; ShowTechTipsViewController * destViewController = segue.destinationViewController; DestViewController.techTipName = [Tectips objectAutandex: indexpath.ro]; }} @ And    

I see what's going on here. You are specifying this visual controller as a data source for both UITableViews but when your techTableView calls your dataSource , There is no way to know that you want to call it your custom dataSource method. You must give your techTableView its self datasource . A separate class that corresponds to the UITableViewDataSource protocol and applies the necessary methods.

No comments:

Post a Comment