나는 일하고있는 탐색 앱을 사용하여 초기 화면 (즉, RootViewController)에서 내 테이블을 볼 수 없습니다. `다음 몇 가지 작업을 수행하고, RootViewController에서 테이블을 볼 수 없습니다.
- (void) locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
`
메소드 호출 :이 방법은 몇 가지 작업을 수행- (void) readRestaurantsFromDatabase:(double)userLatitude
withUserLocation:(double)userLongitude{
을 내 "viewDidLoad에"방법에 의해 호출되는 다음과 같은 방법을
//compile a list of categories
NSMutableArray *categoryList = [[NSMutableArray alloc] init];
[categoryList addObject:@"All Types"];
for (Restaurant *restCat in restaurants){
[categoryList addObject:restCat.category];
}
//remove duplicates
NSArray *copy = [categoryList copy];
NSInteger index = [copy count] - 1;
for (NSString *restCategory in [copy reverseObjectEnumerator]) {
if ([categoryList indexOfObject:restCategory inRange:NSMakeRange(0, index)] != NSNotFound) {
[categoryList removeObjectAtIndex:index];
}
index--;
}
[copy release];
//put list in alphabetical order
sortedArray = [categoryList sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
이 위의 방법이 종료하는 방법입니다 :있는 NSArray는 속성을 선언하고, RootViewController에서 합성이다 "sortedArray"를 불렀다. 그때 내 "cellForRowAtIndexPath"방법에 대해 다음 코드를 : 나에게
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
NSString *cellValue = [sortedArray objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
이 모든 것이 잘 보인다. 코드를 실행하면 콘솔에 출력을 출력하는 NSLog 문이있어서 NSArray sortedArray에 데이터가 있음을 분명하게 나타냅니다. 그러나 Xcode에서 iPhone 시뮬레이터의 코드를 실행하면 빈 테이블이 생깁니다. 누구든지 내가 뭘 잘못하고 있는지 알 수 있니?
미리 답변 해 주신 모든 분들께 감사드립니다.
신속한 답장을 보내 주셔서 감사합니다. 이 코드 블록은 어디에 배치합니까 (즉, 어떤 메소드)? 그것은 될 : cellForRowAtIndexPath 또는 될 것이라고 : readRestaurantsFromDatabase? 도와 줘서 고마워. 조심해. – syedfa
예를 보려면 제 편집을보십시오. 기본적으로 tableView가 보여주고있는 데이터를 변경할 때마다 tableView가 변경되었음을 알릴 필요가 있습니다. – deanWombourne
신속한 도움을 제공해 주셔서 감사합니다. 당신의 솔루션은 효과가있었습니다! 주의를 기울이십시오. – syedfa