2009-12-10 5 views
1

테이블보기에 5 개의 사용자 정의 셀로 구성된 일부 양식이 있습니다. 여기에 코드입니다 :셀 편집을 시도 할 때 UITableView가 충돌 함

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1;} 

\- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return 5; 
} 

\- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    NSLog(@"in here"); 
    static NSString *MyIdentifier = @"MyIdentifier"; 

    FreeSignupCell *cell = (FreeSignupCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 
    if (cell == nil) { 
     NSLog(@"shazam"); 
     cell = [[[FreeSignupCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease]; 
     cell.selectionStyle = UITableViewCellSelectionStyleNone;  
    } 

    switch (indexPath.row) { 
     case 0: 
      NSLog(@"index 0"); 
      [cell setLabelContent:@"First Name"]; 
      //self.firstName = [cell getText]; 
      break; 
     case 1: 
      NSLog(@"index 1"); 
      [cell setLabelContent:@"Last Name"]; 
      //self.lastName = [cell getText]; 
      break; 
     case 2: 
      NSLog(@"index 2"); 
      [cell setLabelContent:@"Company (optional)"]; 
      //self.company = [cell getText]; 
      break; 
     case 3: 
      NSLog(@"index 3"); 
      [cell setLabelContent:@"Website (optional)"]; 
      [cell setText: @"http://"]; 
      //self.website = [cell getText]; 
      break; 
     case 4: 
      NSLog(@"index 4"); 
      [cell setLabelContent:@"E-mail"]; 
      //self.email = [cell getText]; 
      break; 
     default: 
      [cell setLabelContent:@"E-mail"]; 
    } 

    return cell; 
} 

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    return 70.0; 
} 

문제는 그 나는 마지막에 빠르게 스크롤 첫 번째 필드, objc_mssend 오류와 응용 프로그램의 충돌을 편집 할 때.

아이디어가 있으십니까?

+0

FreeSignupCell 클래스의 어딘가에 문제가있는 것 같습니다. 게시 한 코드에서 아무런 문제가 보이지 않습니다. – Vladimir

+0

편집을하지 않고 위아래로 스크롤하면 오류가 발생합니까? FreeSignupCell에 코드를 게시 할 수 있습니까? NSZombie를 켜서 무엇이 해제되는지 확인하십시오. – lyonanderson

+0

아니, 편집하려고 할 때. 시뮬레이터에서는 발생하지만 장치에서는 발생하지 않는다는 것이 흥미 롭습니다. 나는 혼란 스럽다. – Mladen

답변

0

... 여기에 또 다른 문제는 내가 단지 웹 사이트 및 이메일 필드를 참조 페이지에 가입 버튼을 누르면하고 언제 페이지

-(void) SignupAction { 

//Fetching signup data from signup form 
NSIndexPath *path = [NSIndexPath indexPathForRow:0 inSection:0]; 
FreeSignupCell *cell = (FreeSignupCell *)[self.tableView cellForRowAtIndexPath:path]; 
self.firstName = [cell getText]; 

path = [NSIndexPath indexPathForRow:1 inSection:0]; 
cell = (FreeSignupCell *)[self.tableView cellForRowAtIndexPath:path]; 
self.lastName = [cell getText]; 

path = [NSIndexPath indexPathForRow:2 inSection:0]; 
cell = (FreeSignupCell *)[self.tableView cellForRowAtIndexPath:path]; 
self.company = [cell getText]; 

path = [NSIndexPath indexPathForRow:3 inSection:0]; 
cell = (FreeSignupCell *)[self.tableView cellForRowAtIndexPath:path]; 
self.website = [cell getText]; 

path = [NSIndexPath indexPathForRow:4 inSection:0]; 
cell = (FreeSignupCell *)[self.tableView cellForRowAtIndexPath:path]; 
self.email = [cell getText]; 

//JSON Dictionaries require parameters that are not null 
if (self.firstName == nil) { 
    self.firstName = @""; 
} 
if (self.lastName == nil) { 
    self.lastName = @""; 
} 
if (self.company == nil) { 
    self.company = @""; 
} 
if (self.website == nil) { 
    self.website = @""; 
} 
if (self.email == nil) { 
    self.email = @""; 
} 

에서 데이터를 얻고 방법이다. 무슨 일이 일어날지는 변수를 기록 할 때 이메일과 웹 사이트 만 있고 다른 것들은 @ ""입니다. 무슨 일 이니?

0

FreeSignupCell이 사라지면 (말하자면 맨 위 또는 맨 아래로 스크롤되거나 재사용 됨) 해당 소멸 된 셀의 getText가 사라지고 [텍스트 릴리스]가 발생하면, 어떻게됩니까? self.firstName, self.lastName, self.company, self.website 및 self.email 이제는 free() 'd 인 문자열 객체를 참조합니다.

[[cell getText] retain]을 사용해야한다고 생각합니다. 대신.

관련 문제