uitableviewcell source number example data iphone ios ipad ios4

iphone - source - Métodos delegados UITableView



uitableviewcell swift 3 (2)

Necesito un método delegate UITableView que necesite ser llamado desde otra función en tiempo de compilación ... ¿hay algún UITableView delegado UITableView que pueda usar? si no, comente cómo agregar un método de delegado adicional además de los existentes.

Gracias por adelantado


No sé si este método existe, pero si necesita otros métodos en un delegado UITableView , puede crear una nueva categoría de UITableViewDelegate .


Asegúrese de configurar UITableview Delegado Delegado de cualquier manera - desde NIB o programatialmente

Usando NIB From Nib: -

Programaticamente:

entonces:-

-(void)viewWillAppear:(BOOL)animated { tblService.delegate=self; tblService.dataSource=self; [super viewWillAppear:YES]; }

Use los siguientes delegados:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; //count of section } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [catagorry count]; //count number of row from counting array hear cataGorry is An Array } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; } // Here we use the provided setImageWithURL: method to load the web image // Ensure you use a placeholder image otherwise cells will be initialized with no image [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder"]]; cell.textLabel.text = @"My Text"; return cell; }

Below use for set height of cell

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 80; }

Below use for gatting particular cells data by selecting row this method called

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ Yourstring=[catagorry objectAtIndex:indexPath.row]; //Pushing next view cntrSecondViewController *cntrinnerService = [[cntrSecondViewController alloc] initWithNibName:@"cntrSecondViewController" bundle:nil]; [self.navigationController pushViewController:cntrinnerService animated:YES]; }