我的應用程序是基於coreData的,使用mapKit和現場註釋。該應用程序運行所有功能;主要的問題是,當我在這個文本字段上輸入一個新的位置時,這個新點並不像它應該顯示在表視圖中。只有當我重新啓動應用程序時,表格纔會刷新,儘管有tableview重新加載指令,新點仍然可用。有沒有人有線索爲什麼會發生這種情況,我怎麼能解決它? 謝謝。爲表視圖 代碼:IOS/Objective-c:問題與「實時」保存到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) – FuManchu