Rahul Vyas
Rahul Vyas

Reputation: 28740

how to reload or refresh a view in iphone?

i have a uitableviewcontroller here is the .h file code

@interface addToFavourites : UITableViewController {

}

@end

and here is the .m file code

#import "addToFavourites.h"


@implementation addToFavourites

- (id)initWithStyle:(UITableViewStyle)style {
    if (self = [super initWithStyle:style]) {
    }
    return self;
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *MyIdentifier = @"MyIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
    }
    // Configure the cell

    return cell;
}

@end

and in another class i am showing this view using this code

addToFavouritesobj = [[addToFavourites alloc] initWithStyle:UITableViewStylePlain];
        [self.navigationController pushViewController:addToFavouritesobj animated:YES]; 

how do i call reload method of this uitableviewcontroller class?

there is no need of declaring tableview because this view automatically genrating a table

i am very confused how to reload the table?

Upvotes: 2

Views: 33318

Answers (1)

Kornel
Kornel

Reputation: 100200

addToFavouritesobj.tableView will give you access to the UITableView object.

[addToFavouritesobj.tableView reloadData]

BTW: class names should start with capital letter. A better name for your class would be AddToFavouritesController.

Upvotes: 12

Related Questions