2011-10-19 3 views
1

상당히 큰 목록을 생성하는 사전 값 어레이가있는 uitableview가 있습니다. 사용자가 선택할 수있는 .. 사용자가 셀을 선택하면 탐색 스택에서보기를 팝하고 모든 값을 기본보기로 다시 전달합니다. 사용자가 만든 경우이보기로 돌아갈 수 있습니다. 실수로 자신의 의견을 바꾸고 싶습니다.앱 전화로 테스트 할 때 UITableViewScrollPositionMiddle로 인해 충돌이 발생합니다.

해당보기로 다시 돌아 가면 UITableViewScrollPositionMiddle을 사용하여 이전에 선택한보기로 자동 스크롤하는 방법이 있습니다.

그러나 에뮬레이터가 정상적으로 작동하므로 전화기에서 사용할 때 오류가 발생한다고 생각합니다. 나는 오류가

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
    //Center previously selected cell to center of the screen 
    [self.tableView scrollToRowAtIndexPath:oldCheckedData atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; //<--- this method 
} 

일어나고 있다고 생각 어디 여기

이며이 내 휴대 전화에 구축 할 때 내가 로그에서 얻을 오류입니다. 이 오류를 얻으려면 사용자가 하위보기를로드하는 상위보기의 셀을 클릭하기 위해 사용자가 하위보기의 셀을 선택하고 상위보기로 되돌아갑니다. 그러면 사용자가 돌아올 때 같은 하위 뷰에 로그에 표시됩니다.

2011-10-19 15:00:05.790 icode[1564:707] -[__NSArrayM section]: unrecognized selector sent to instance 0x181cd0 
2011-10-19 15:00:05.797 icode[1564:707] CoreAnimation: ignoring exception: -[__NSArrayM section]: unrecognized selector sent to instance 0x181cd0 

는 는 사용자가 다른 셀이 앱 충돌 선택이 어떤 도움을 크게 감상 할

2011-10-19 15:01:08.272 icode[1564:707] -[__NSArrayM row]: unrecognized selector sent to instance 0x181cd0 
2011-10-19 15:01:08.275 icode[1564:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM row]: unrecognized selector sent to instance 0x181cd0' 
*** First throw call stack: 
(0x35e9e8b3 0x366e61e5 0x35ea1acb 0x35ea0939 0x35dfb680 0x334a76cf 0x3353c713 0x30e1d 0x3352cd69 0x335a60ab 0x35cc32ab 0x35e72a57 0x35e726bd 0x35e71293 0x35df44e5 0x35df43ad 0x30fa4fed 0x334a7dc7 0x24f7 0x24a0) 
terminate called throwing an exception(gdb) 

로그에 표시 (더 스크롤 효과 없음).

있는 tableview 데이터 소스

그것은 당신이보기 컨트롤러가 스택에서 팝 때 oldCheckedData 할당이 해제되었을 수 있습니다에 대한 참조를 가지고있는 인덱스 경로처럼 보이는
#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    // Return the number of sections. 
    return [arraysByLetter count]; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    NSString *currentLetter = [sectionLetters objectAtIndex:section]; 
    return [[arraysByLetter objectForKey:currentLetter] count]; 
} 

/* 
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{  
    //override state-based properties set earlier by the table view, such as selection and background colorset up shit here 
} 
*/ 

- (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]; 
    } 

    //Customize cell here 
    cell.selectionStyle = UITableViewCellSelectionStyleNone; // no blue selection 

    //Replaces previously selected cells accessory view (tick) 
    if (indexPath == oldCheckedData) 
    { 
     cell.accessoryType = UITableViewCellAccessoryCheckmark; 
    } 
    else 
    { 
     cell.accessoryType = UITableViewCellAccessoryNone; 
    } 

    //Display cells with data 
    NSArray *keys = [self.arraysByLetter objectForKey:[self.sectionLetters objectAtIndex:indexPath.section]]; 
    NSString *key = [keys objectAtIndex:indexPath.row]; 

    cell.textLabel.text = key; 
    return cell; 
} 

//Section headers 
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{ 
    return [sectionLetters objectAtIndex:section]; 
} 

//Section header titles 
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView 
{ 
    return sectionLetters; 

} 
+0

TableViewDataSource 메서드를 보여주는 코드를 게시하십시오. 로그에서 행 및 섹션 메서드를 응용 프로그램을 충돌시키는 Array 객체에 전달하고 있습니다. 또한 소스 코드를 컴파일 할 때 컴파일러 경고를보십시오. – 0x8badf00d

+0

빌드 할 때 경고가 없습니다 .. 내 TableViewDataSource 메서드를 사용하여 코드를 업데이트했습니다. –

답변

0

. 보기 컨트롤러가 사라지기 전에 그것을 유지해야합니다.

+0

잘 에뮬레이터에서 oldCheckedData 제대로 작동합니다. 그것은 정확한 상단으로 스크롤하고 올바른 indexpath에 진드기를 assing .. 그럼 확실하지 않은 경우 ... NSW는 oldCheckedData 또한 괜찮은 것 같습니다. –

+0

'oldCheckedData'가 할당 해제되었지만 여전히 부모 vc의 참조가 가리키는 메모리 위치에있을 가능성이 있습니다. 시뮬레이터에서 작업 할 메모리가 더 많으므로 아직 재사용되지 않았을 수 있습니다. 전화 기억은 다른 이야기입니다. –

+0

'[self.tableView scrollToRowAtIndexPath : oldCheckedData atScrollPosition : UITableViewScrollPositionMiddle animated : YES];에 중단 점을 설정하고 서브 뷰를 다시로드 할 때'oldCheckedData'가 무엇인지보십시오. –

관련 문제