ios - UIView 内部的 UITableView 与第一个单元格静态

标签 ios ios5 uitableview uipickerview

我在 View 中有一个 TableView ,因为我在屏幕底部有一个 uipicker。现在我想更改受 uipicker 影响的 TableView 中的第一行。所以我需要一个静态的第一行,其他行应该是动态的。

第一行是一个标签和一个按钮。

这可能吗?

我的代码:

- (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;
}

谢谢 4 的帮助。

最佳答案

是的,这是完全可以接受的,而且您看起来做得很好。

但是,当您的选择器值发生变化时,您应该在 tableView 上调用 reloadData,以便它知道选择 StaticCell 的新值。

关于ios - UIView 内部的 UITableView 与第一个单元格静态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9829853/

相关文章:

ios - 取消 Apple 自动续订订阅

iphone - 对象旋转不正确 - iPhone 应用程序

ios - Xcode 5 Your binary is not optimized for iPhone 5 验证时出现错误

objective-c - 检查整个枚举的相等性?

objective-c - 从数组中抓取项目时崩溃... objective-c

ios - 如何评估ios中的字符串方程

ios - 如何将 segue 从 TableView 中的单元格单击推送到另一个 View Controller

ios - 同时使用 TableFooterView 和行操作时 TableView 分隔符的奇怪行为

ios - 重新加载表格动画

ios - 一个 ViewController 可以包含多个父(即包含) Controller 吗?