내 UITableView로 아주 간단한 작업을하고 싶습니다. UIActivityIndicatorView를 섹션의 헤더보기에 추가하고 싶을 때마다 애니메이션을 적용하거나 사라지게 만들려고합니다. viewForHeaderInSection :UITableView의 섹션 헤더보기에서 UIActivityIndicatorView에 액세스하는 방법?
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 60.0)];
// create the title
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(15.0, 12.0, 310.0, 22.0)];
headerLabel.text = @"some random title here";
[customView addSubview:headerLabel];
[headerLabel release];
// Add a UIActivityIndicatorView in section 1
if(section == 1)
{
[activityIndicator startAnimating];
[customView addSubview:activityIndicator];
}
return [customView autorelease];
}
activityIndicator 내 컨트롤러 클래스의 속성입니다
내가있는 tableView를 사용하여 헤더보기에 UIActivityIndicatorView를 추가 아무런 문제가 없었다. 내가이있는 viewDidLoad 방법에 ALLOC :- (void)viewDidLoad
{
(...)
activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(200, 10, 25, 25)];
}
이 방법을 내가 메시지를 보낼 수 있습니다 (-startAnimating 또는 -stopAnimating처럼) 내가 원할 때마다. 문제는 activityIndicator가 tableView를 스크롤하자마자 사라진다는 것입니다 (tableView : viewForHeaderInSection : 메서드가 두 번째로 호출 되었기 때문입니다).
기타 어떻게 그 섹션의 헤더보기에 activityIndicatorView를 추가하고 나중에 메시지를 보낼 수 있습니까? (물론 아래로 스크롤하면 activityIndicator가 사라지지 않습니다.)
대단히 고마워요!
activityIndicator를 여러 위치에 하나씩 갖고 싶지 않습니다. – nmondollot
그게, 서브 뷰를 계속 추가하려고하는 다른 이유를 상상할 수 없기 때문에 당신이하려고했던 것처럼 보입니다. – Nimrod