我有一个 uitableviewcontroller 这是.h文件代码
@interface addToFavourites : UITableViewController {
}
@end
这是 .m 文件代码
#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
在另一个类(class)中,我使用此代码显示此 View
addToFavouritesobj = [[addToFavourites alloc] initWithStyle:UITableViewStylePlain];
[self.navigationController pushViewController:addToFavouritesobj animated:YES];
如何调用此 uitableviewcontroller
类的重新加载方法?
不需要声明tableview,因为该 View 会自动生成表格
我很困惑如何重新加载表格?
最佳答案
addToFavouritesobj.tableView
将使您能够访问 UITableView
对象。
[addToFavouritesobj.tableView reloadData]
<小时/>
顺便说一句:类名应该以大写字母开头。更好的类名称是 AddToFavouritesController
。
关于objective-c - 如何在 iPhone 中重新加载或刷新 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/959380/