У меня большая проблема.
[self.tableView reloadData];
Не работает, и я не понимаю, почему.
[[self tableView] reloadData];
Тоже не работает.
Вот мой код:
.h
@interface ArticleViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate>
{
}
@end
.m
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.dataSource = self;
self.tableView.delegate = self;
}
btnLeft = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btnLeft"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(loadPlist)];
self.navigationItem.leftBarButtonItem = btnLeft;
В методе loadPlist
я пишу в файле .plist. Эта часть работает нормально.
Как только все будет записано в файл .plist:
btnRight = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btnRight"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(reloadTheTB)];
self.navigationItem.rightBarButtonItem = btnRight;
- (void)reloadTheTB {
NSLog(@"Test reloadTheTB");
[[self tableView] reloadData];
}
Если я коснусь btnRight
, я увижу в журнале "Test reloadTheTB
".
Вот tableView:cellForRowAtIndexPath:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
cell = [self getCellContentView:CellIdentifier];
contentDictio = [dict objectAtIndex:indexPath.row];
UILabel *lblTemp1 = (UILabel *)[cell viewWithTag:1];
lblTemp1.text = [contentDictio objectForKey:@"title"];
if(indexPath.row % 2) {
UIView* myBackgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
myBackgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_grise"]];
cell.backgroundView = myBackgroundView;
}
else {
UIView* myBackgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
myBackgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_blanche"]];
cell.backgroundView = myBackgroundView;
}
}
return cell;
}
ОБНОВЛЕНИЕ:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [dict count];
}
Помоги мне, пожалуйста...
[tableView reloadData]
- person mayuur   schedule 30.10.2012UITableViewController
, поэтому мне не нужно создавать tableView - person user1269586   schedule 30.10.2012tableView:cellForRowAtIndexPath:
? Похоже, что происходит то, что модель, из которой вы получаете данные вtableView:cellForRowAtIndexPath:
для заполнения ячеек, не обновляется путем записи файла .plist или чего-то еще, что вы делаете. - person diederikh   schedule 30.10.2012- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier
- person user1269586   schedule 31.10.2012