2012-03-22 11 views
0

画面の下部にuipickerがあるため、ビュー内にtableviewがあります。今私はuipickerの影響を受けたテーブルビュー内の最初の行を変更したい。だから私は静的な最初の行が必要とし、他の行は動的でなければなりません。最初のセルが静的であるUIView内のUITableView

最初の行にはラベルとボタンがあります。

これは可能ですか?

私のコード:

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component 
{ 
    return [_pickerValues count]; 
} 


-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component 
{ 
    return [_pickerValues objectAtIndex:row]; 
} 

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component 
{ 
    //What should I do to get the first row label without remove uibutton inside 
} 


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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    // Return the number of rows in the section. 
    return 1 + 4; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSString *CellIdentifier = @"DynamicCell"; 

    if ([indexPath row] == 0) { 
     CellIdentifier = @"StaticCell"; 
    } 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    // Configure the cell... 
    if (indexPath.row > 0) { 
     UILabel *value = (UILabel*)[cell viewWithTag:0]; 
     //... 
    } 

    return cell; 
} 

Thxを4ヘルプ。

答えて

2

はい、これは完全に受け入れられ、正しく実行されているように見えます。

しかし、ピッカー値が変更された場合は、スタティックセルの新しい値を取得するようにtableViewでreloadDataを呼び出す必要があります。

+0

またはアニメーションが必要な場合は 'reloadRowsAtIndexPaths:withRowAnimation:') –

+0

thxこのアニメーションのヒント –

+0

とthx @Taylor Dondichがあなたのアドバイスをしてくれます! –

関連する問題