2011-10-07 43 views
0
-(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,但它調用numberOfRowsInSectionviewDidLoad方法,但不調用cellForRowAtIndexPath方法。但是當我轉到其他屏幕並再次回來時,它會從開始刷新我的List如何刷新的UITableViewController在iPhone/iPad的

可能是什麼原因?請幫助我是iPad開發新手。我正在iPad上做所有這些。

非常感謝

EDITED

@interface StudentsList : UITableViewController { 
DetailViewController *detailViewController; 
UIToolbar *toolbar; 
UIActivityIndicatorView *activityIndicator; 
} 
+0

'numberOfRowsInSection'返回的是否爲零? – Nekto

+0

是的,它確實..它返回5 – Shah

+0

移動'[超級viewDidLoad];'頂部的' - (void)viewDidLoad {' – Nekto

回答

0

可能是你的data.count爲0?如果有一些數據應該經過[[self tableView] reloadData];

+0

是的,首先它有五個記錄,然後當我刷新它仍然顯示五條記錄我的意思是我不添加任何更多的數據到dataArray,但只是想要它刷新.....任何想法??我怎麼能做這個?? – Shah

0

調用的cellForRowAtIndexPath執行刷新代碼在另一個單獨的方法​​然後再調用這個,只要你想,如-viewDidLoad或按鈕上自來水......

0

試圖調用- (void)reloadView from

-(void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    [self reloadView]; 
}