我需要一个UITableView
委托方法,需要在编译时从另一个函数中调用...是否有任何默认UITableView
我可以使用的委托方法?如果没有,请评论如何添加一个额外的委托方法,除了现有的。UITableView委托方法
在此先感谢
我需要一个UITableView
委托方法,需要在编译时从另一个函数中调用...是否有任何默认UITableView
我可以使用的委托方法?如果没有,请评论如何添加一个额外的委托方法,除了现有的。UITableView委托方法
在此先感谢
确保在任一方式设置UITableview
代表 - 从NIB
或programatially
使用NIB 从笔尖: -
编程方式: -
然后: -
-(void)viewWillAppear:(BOOL)animated
{
tblService.delegate=self;
tblService.dataSource=self;
[super viewWillAppear:YES];
}
使用下列代表:
- (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];
}
http://stackoverflow.com/questions/5831813/delegate-and-datasource-methods-for-uitableview/42105964#42105964 –
我不知道,如果这种方法存在,但如果你需要在一个UITableView
委托其他方法可以创建UITableViewDelegate
一个新的类别。
做ü需要从另一个函数刷新的tableView ??? – AppleDelegate
你为什么要创建委托方法?相反,您可以在完成功能 –
后重新加载所有表格数据,请提供有关该问题以及您想要实现的更多信息。 – Kassem