私のアプリはcoreDataベースでmapKitとスポットアノテーションを使用しています。アプリはすべての機能で動作します。主な問題は、このテキストフィールドに新しい場所を入力すると、この新しい場所がテーブルビューに表示されないように見えるということです。アプリを再起動したときにのみ、テーブルがリフレッシュされ、テーブルビューのリロード命令があるにもかかわらず、新しいスポットが使用可能になります。誰にもこれがどうして起こり、どのように修正できるのかという手掛かりはありますか? ありがとうございます。テーブルビューの コード:IOS/Objective-c: "real time"の問題がcoreDataに保存される
@interface TableViewController()
@property (strong) NSMutableArray *lisbonSpots;
@end
@implementation TableTableViewController
- (IBAction)delete:(UIBarButtonItem *)sender {
self.tableView.editing = !self.tableView.editing;
}
- (void)viewDidLoad {
[super viewDidLoad];
//_bar=[Spot spotType:@"bar"];
self.tableView.dataSource = self;
_lisbonSpots = [[Spot allSpots]mutableCopy];
NSLog(@"The Core Spots are: %@", _lisbonSpots);
[self.tableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.lisbonSpots.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
NSManagedObject *ls = [self.lisbonSpots objectAtIndex:indexPath.row];
NSLog(@"Table Spots are: %@", ls);
[cell.textLabel setText:[NSString stringWithFormat:@"%@", [ls valueForKey:@"name"]]];
cell.imageView.image = [UIImage imageNamed:@"city.jpg"];
return cell;
}
は、メインスレッド上でtableview.reloadDataと呼ばれてい?? –
私たちが手助けできるようにいくつかのコードを表示 –
TableViewController(didLoad)にtableview.reloadDataがあります – FuManchu