2012-05-11 8 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に割り当て、テーブルをリロードする必要があります。

関連する問題