2012-03-25 4 views
-1

사용자 정의 UITableViewCell을 작성하고 UIProgressView에 셀을 추가합니다. 왜냐하면 UITableView에 행을 추가 할 때 XML 데이터에서 정보를 다운로드하기 때문입니다. ProgressView를 사용하여 프로세스의 진행 상태를 보여주고 싶습니다. 내 질문은 진행률 막대를 변경해야하는 인덱스 행을 어떻게 감지 할 수 있습니까? 그리고 방금 만든 행의 인덱스 경로는 무엇입니까? ? 에서사용자 정의 UITableViewCell에 UIProgressView를 추가하고 인덱스 행이 무엇인지 감지합니다.

:

cellForRowAtIndexPath:(NSIndexPath *)indexPath 

내가 이런 식으로 단골있는 UITableViewCell에서 정보를 검색 :

UILabel *label; 

label = (UILabel *)[cell viewWithTag:1000]; 
label.text = [[managedObject valueForKey:@"firstName"] description]; 

그래서 난 후 변경, 추가 한 행의 인덱스 경로 행을 알 수있는 방법 진행률 표시 줄?

+0

안녕하세요 @Piero는 progressview의 태그를 지정하고 값을 가져오고 싶거나 progressview의 값을 셀에서 태그로 가져 오려는 경우이 값을 변경하려고합니다. – Leena

+0

그래,하지만 어떻게 인덱스가 셀을 가지고 있는지 알아? – Piero

+0

progressView.tag = indexPath.row를 설정하고 progressview와 함께하고 싶은 작업을 수행하십시오. – Leena

답변

0

나는 당신이 무엇을 요구하고 있는지 이해하지 못한다고 생각합니다. indexPath는 방금 작성한 행의 IndexPath입니다. 이 값으로 속성을 설정했지만 해당 속성에는 만든 마지막 행의 IndexPath 만 포함됩니다. 예를 표시하도록 업데이트

:

방법 1 - 당신은 cellForRowAtIndexPath 내에서 다른 메소드를 호출하지 않습니다.

#import "MyViewController.h" 

@interface MyViewController() 
    @property(nonatomic,strong) NSIndexPath *lastIndexPathCreated; 
@end 

@implementation MyViewController 
@synthesize lastIndexPathCreated; 
: 당신의하는 .m 파일에

:이 경우, 당신은 형 NSIndexPath의 개인 재산을해야합니다 (단 사유 재산 선언을 넣어하는 방법을 보여 MyViewController 가져 오기 및 @interface 선언에 대한 코드를 포함

...

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
// All your other cell setup code 

self.lastIndexPathCreated = indexPath; 
return cell; 
} 

-(void)someOtherMethod { 
    // The last IndexPath of the row LAST created is self.lastIndexPathCreated 
} 

방법 2 :

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    // All your other cell setup code 
    [self myOtherMethodWithIndexPath:indexPath]; 
    return cell; 
} 

-(void)myOtherMethodWithIndexPath:(NSIndexPath *)lastIndexPath { 
    // Do something with lastIndexPath 
} 
: 이것은 당신이 cellForRowAtIndexPath 내에서 다른 메소드를 호출 가정

희망이 도움이

+0

코드에서 다른 방법으로 방금 작성한 마지막 행의 인덱스 경로를 검색하는 방법은 무엇입니까? 진행보기? – Piero

+0

답변을 주셔서 대단히 감사합니다. 그러나 행을 추가하고 코어 데이터 (여기서 행에 대한 정보를 검색하는 곳)에 삽입 할 데이터를로드하면 cellrowforindex 경로가 테이블보기의 모든 행을 다시로드하고 lastIndexPathCreated 테이블 뷰의 위치를 ​​변경하므로 인덱스 경로도 변경합니다. – Piero

+0

예, IndexPath는 tableview의 모든 행에 대해 변경됩니다. –

관련 문제