-(void)reloadView{
NSLog(@"IN RELOAD VIEW ");
[[self tableView] reloadData];
}
- (void)viewDidLoad {
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView:activityIndicator];
[self navigationItem].rightBarButtonItem = barButton;
[activityIndicator startAnimating];
[self callStudentsWebService];
[super viewDidLoad];
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
[self setTitle:@"Students"];
self.navigationController.toolbarHidden = NO;
self.navigationController.toolbar.barStyle = UIBarStyleBlack;
UIBarButtonItem *add = [[UIBarButtonItem alloc] initWithTitle:@"Add Student" style:UIBarButtonItemStyleBordered target:self action:@selector(addStudent)];
UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *import = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(addStudent)];
NSArray* toolbarItems = [NSArray arrayWithObjects:add,flexible,import, nil];
self.toolbarItems = toolbarItems;
}
以上是我在一类是UITableViewController
一个子类代码。 现在我的问题是,当我第一次来到屏幕上时,它从方法[self callStudentsWebService]
的Web服务中获取记录。现在我在uitoolbar
中有一个按钮,它在更新列表的相同视图中。我正在调用reloadView
方法刷新List
,但它调用numberOfRowsInSection
和viewDidLoad
方法,但不调用cellForRowAtIndexPath
方法。但是当我转到其他屏幕并再次回来时,它会从开始刷新我的List
。如何刷新的UITableViewController在iPhone/iPad的
可能是什么原因?请帮助我是iPad开发新手。我正在iPad上做所有这些。
非常感谢
EDITED
@interface StudentsList : UITableViewController {
DetailViewController *detailViewController;
UIToolbar *toolbar;
UIActivityIndicatorView *activityIndicator;
}
'numberOfRowsInSection'返回的是否为零? – Nekto
是的,它确实..它返回5 – Shah
移动'[超级viewDidLoad];'顶部的' - (void)viewDidLoad {' – Nekto