iOS: UITableView delegate methods

Connect UITableview first with two way first is from NIB and second with coding
Using NIB just connect Event table to file owner and connect delegate like :-
enter image description here
and then other second way is with coding like :- enter image description here
         [super viewWillAppear:YES];
Basically iphone UITableView used below Delegate method's used
- (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:@""]
                       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];


iOS: UITableView delegate methods iOS: UITableView delegate methods Reviewed by Unknown on 12:29 Rating: 5

No hay comentarios:

Con la tecnología de Blogger.