Ios 是否有办法在InAppSettingsKit中动态定义单元格值?

Ios 是否有办法在InAppSettingsKit中动态定义单元格值?,ios,inappsettings,Ios,Inappsettings,似乎出于自然原因,所有东西都通过连接从Settings.bundle值获取其信息 但看看示例epp中的“应用程序信息”,它的版本硬编码为“1.0”。在我现在使用的设置屏幕(自制)中,我动态获取并显示它。是否有某种方法可以覆盖那里显示的内容 如果有一个“单元格说明符的动态值”或者您可以重写的东西,那就太好了,这样我就可以为该单元格编写一个从主捆绑包的CbundleShortVersionString获取的方法。我还有其他使用案例,我希望从服务器获取和写入动态多选值,但不确定是否能够使其与此api一

似乎出于自然原因,所有东西都通过连接从Settings.bundle值获取其信息

但看看示例epp中的“应用程序信息”,它的版本硬编码为“1.0”。在我现在使用的设置屏幕(自制)中,我动态获取并显示它。是否有某种方法可以覆盖那里显示的内容


如果有一个“单元格说明符的动态值”或者您可以重写的东西,那就太好了,这样我就可以为该单元格编写一个从主捆绑包的CbundleShortVersionString获取的方法。我还有其他使用案例,我希望从服务器获取和写入动态多选值,但不确定是否能够使其与此api一起工作。

如果我正确回答了您的问题-下面是我如何将自动应用程序版本添加到InAppSettingsKit视图中的

在Settings.bundle中的Root.inApp.plist(或Root.plist)中,将版本字段的类型设置为IASKCustomViewSpecifier:

<dict>
    <key>DefaultValue</key>
    <string>1.5</string>
    <key>Key</key>
    <string>version</string>
    <key>Title</key>
    <string>VERSION</string>
    <key>Type</key>
    <string>IASKCustomViewSpecifier</string>
</dict>
现在您可以使用这些委托方法(仅对
IASKCustomViewSpecifier
字段调用它们):

以下是我的实现:

- (UITableViewCell*)tableView:(UITableView*)tableView cellForSpecifier:(IASKSpecifier*)specifier {
    NSString *identifier = [NSString stringWithFormat:@"%@-%ld-%d", specifier.type, (long)specifier.textAlignment, !!specifier.subtitle.length];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
    }
    if ([specifier.key isEqualToString:@"version"]) {
        [cell.textLabel setText:specifier.title];
        [cell.detailTextLabel setText:[NSString stringWithFormat:@"%@ (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
    }
    NSLog(@"Cell key: %@", specifier.key);
    return cell;
}
- (CGFloat)tableView:(UITableView*)tableView heightForSpecifier:(IASKSpecifier*)specifier {
    return 44.0f;
}
结果如下:

- (CGFloat)tableView:(UITableView*)tableView heightForSpecifier:(IASKSpecifier*)specifier;
- (UITableViewCell*)tableView:(UITableView*)tableView cellForSpecifier:(IASKSpecifier*)specifier;
- (UITableViewCell*)tableView:(UITableView*)tableView cellForSpecifier:(IASKSpecifier*)specifier {
    NSString *identifier = [NSString stringWithFormat:@"%@-%ld-%d", specifier.type, (long)specifier.textAlignment, !!specifier.subtitle.length];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
    }
    if ([specifier.key isEqualToString:@"version"]) {
        [cell.textLabel setText:specifier.title];
        [cell.detailTextLabel setText:[NSString stringWithFormat:@"%@ (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
    }
    NSLog(@"Cell key: %@", specifier.key);
    return cell;
}
- (CGFloat)tableView:(UITableView*)tableView heightForSpecifier:(IASKSpecifier*)specifier {
    return 44.0f;
}