2012-05-11 4 views
0

그래서 iOS 용 응용 프로그램을 구축 중이며 많은 것들을 계산하여 화면에 표시하려면 -(IBAction)calculate으로 가져 왔습니다. 또한 잘라내 목록이 될 증분 배열을 만듭니다. 보기의 한쪽 아래로 공백 인 UITableView이 있습니다. 나는 viewDidLoad 후에 그것을 가지고있다. 이제 계산 버튼을 누르면이 목록에 증가하는 절단 목록이 채워집니다. 나는 이것에 저를 도울 어떤 자습서 또는 등을 발견 할 수 없다.버튼 터치에서 UITableView를 채우는 방법

계산 작업에 넣을 때만 오류가 발생합니다. 그래서 나는 viewDidLoad 다음에 남겨두고 버튼 터치에서 그것을 채우기를 바랐다.

// Customize the number of sections in the table view. 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
return 1; 
} 

// Customize the number of rows in the table view. 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
return [creeperArray count]; 
} 

// Customize the appearance of table view cells. 
- (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. 
[cell.textLabel setText:[creeperArray objectAtIndex:indexPath.row]]; 

return cell; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

/* 
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; 
// ... 
// Pass the selected object to the new view controller. 
[self.navigationController pushViewController:detailViewController animated:YES]; 
[detailViewController release]; 
*/ 
} 

답변

3

reloadData에 테이블보기를주기 : 여기

내가 가진 것입니다. 위임자와 데이터 소스가 올바르게 설정되어 있고 creeperArray에 표시하려는 항목이 포함되어 있으면 제대로 작동합니다. 당신은 당신의있는 UIButton 행동과 array.Anyways에 대한 코드 정보를 제공하지 않은

(그렇지 않다면, 당신이 더 많은 정보를 제공해야합니다.)

+0

감사합니다. –

0

, 당신은 당신의 creeperArray에 변화하는 배열을 지정해야합니다 배열이 바뀔 때마다 테이블을 다시로드합니다.

변경된 배열이 다른 클래스 인 경우 동일한 속성에 대한 속성을 정의하고 역방향 데이터 흐름의 경우 프로토콜 대리자를 사용해야하는 일부 전달 클래스에 액세스해야합니다.

배열이 tableview와 동일한 viewcontroller에있는 경우 변경 배열의 내용을 creeperArray에 할당하고 테이블을 다시로드해야합니다.

관련 문제