How check or to load otherView when UITableView is empty?
I am try to create the Table test application . I use table view for that .I need When there is no data in table or when table is empty other view must c开发者_开发百科ome instance table view .How can do this.Please give honest answer . thanks
In these two delegates check if you have cells in your table. If not present your custom view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return NumberOfSections;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return NumberOfRows;
}
Create custom table cell and when there is no data then return 1 in numberOfRowsInSection and in cellForRowAtIndexPath return custom cell with what ever view you want
good luck
Correct me if I am wrong. I think you will be using an array or something to fill the contents of the tableView. So when you load the view you can check if the contents are available for the tableview. If the array is empty then you can show the other view instead of the tableview.
UPDATE
This tutorial is a nice place to start.
精彩评论