我是Objective-C的新程序员,在我的第一个应用程序中遇到了一个可怕的问题。
我有一个名为Places
(NSObject
)的课程,我在Google的地方找到了地方并返回了NSArray
。
我有另一个名为qazxsw poi(qazxsw poi)的课程。这个类导入我的“Place.h”。
在我的DisplayPlaces
我有这个代码:
UiViewController
在我的方法viewDidLoad
我加载JSON URL并将结果放入Places *places = [[Places alloc]init];
[places.locationManager startUpdatingLocation];
[places LoadPlaces:places.locationManager.location];
[places.locationManager stopUpdatingLocation];
[places release];
后我得到的地方并放入LoadPlaces
并返回。
进入我的NSDictionary
我分配我的NSArray
并调用方法Places
返回我找到的地方。
DisplayPlaces
一切正常。
我的问题是:
在我的ReturnPlaces: NSArray
中,我打电话给- (void)ReturnPlaces:(NSArray *)locais{
placesArray = locais;
[self.UITableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [placesArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIndentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIndentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIndentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = [placesArray objectAtIndex:indexPath.row];
return cell;
}
,但我无法刷新我的UiTableView。
我能做什么?
将您的tableview ReturnPlaces: NSArray
设置为您的财产并使用
[MyUiTableView reloadData]
如果你在tableView的任何方法内重新加载,只需使用
yourTableView
如果你在tableView方法之外重新加载,请使用
self.yourTableView = tableView; // for assigning the tableView contents to your property
您是否在tableView的实例上调用reloadData。换句话说,如果你有
[tableView reloadData];
然后重新加载它需要你打电话
[self.yourTableView reloadData];
不
MyUITableView *mytableView;