我有以下实现,其中$db->abcd
和表格单元格上有两个按钮(标题为#!/usr/bin/env groovy
pipeline {
agent any
parameters {
string(defaultValue: '', description: 'Delivery name', name: 'DELIVERY')
choice(choices:'DEV1\nDEV2\nDEV3',description: 'Select Source environment', name: 'SOURCE_ENV')
choice(choices:'TEST1\nTEST2\nTEST3',description: 'Select target environment', name: 'TERGET_ENV')
choice(choices:'Yes\nNo',description: 'Generate Report?', name: 'GENREPORT')
}
stages {
stage("Start Batch") {
steps {
bat '''
echo '${params.DELIVERY}'
echo '${params.SOURCE_ENV}'
echo '${params.TERGET_ENV}'
echo '${params.GENREPORT}'
cd "C:\\Users\\DELIVERY_BATCH\\src"
cscript.exe DELEXCEBATCH.vbs "C:\\Users\\Documents\\BatchFiles" ${params.DELIVERY} ${params.SOURCE_ENV} ${params.TERGET_ENV} ${params.GENREPORT}
EXIT /B 0
'''
}
}
stage("Create Summary Excel sheet") {
steps {
bat '''
echo 'Batch Execution is successful'
'''
}
}
}
}
和title
)。当用户选择并关闭该部分并再次打开时,他只会看到按钮标题的默认值half
而不是他的选择。
我能够看到以下方法(full
)在重新加载期间被调用,但它没有任何效果。
代码和截图如下。
full
答案 0 :(得分:2)
您正在从setHalfButton
数据源方法调用setFullButton
和cellForRowAtIndexPath:
函数,但它们正在调用cellForRowAtIndexPath:
tableview方法。由于您还没有从前一种方法返回单元格,后一种方法会将nil
返回cell
,导致无法更新。
setHalfButton
和setFullButton
方法应该在ComboTableViewCell
类中:
-(void) setHalfButton
{
[self.halfBtnOutlet setTitleColor:[UIColor colorWithRed:0 green:102.0f/255.0f blue:0 alpha:1] forState:UIControlStateNormal];
[self.fullBtnOutlet setTitleColor:[UIColor colorWithRed:0.5f green:0.5f blue:0.5f alpha:1] forState:UIControlStateNormal];
[self.halfBtnOutlet.titleLabel setFont:[UIFont boldSystemFontOfSize:15.f]];
[self.fullBtnOutlet.titleLabel setFont:[UIFont systemFontOfSize:15.f]];
}
-(void) setFullButton
{
[self.fullBtnOutlet setTitleColor:[UIColor colorWithRed:0 green:102.0f/255.0f blue:0 alpha:1] forState:UIControlStateNormal];
[self.halfBtnOutlet setTitleColor:[UIColor colorWithRed:0.5f green:0.5f blue:0.5f alpha:1] forState:UIControlStateNormal];
[self.fullBtnOutlet.titleLabel setFont:[UIFont boldSystemFontOfSize:15.f]];
[self.halfBtnOutlet.titleLabel setFont:[UIFont systemFontOfSize:15.f]];
}
此外,每次出列单元格时都会添加按钮操作处理程序,但只应在分配新单元格时执行此操作。从设计的角度来看,这些按钮点击处理程序也应该在具有委托模式的ComboTableViewCell
类中,以通知视图控制器半/完全被更改。
至少看起来应该是这样的:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"ComboCell";
ComboTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[ComboTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
[cell.halfBtnOutlet addTarget:self action:@selector(halfBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
[cell.fullBtnOutlet addTarget:self action:@selector(fullBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
}
if([selectedRowsInSectionDictionary[@(indexPath.section)] containsObject: indexPath])
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
if(
comboItemsArray[indexPath.section].allComboItems[indexPath.row].pQuantity == 0.5)
{
// it comes here after reloading
[cell setHalfButton];
}
else
{
[cell setFullButton];
}
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell.halfBtnOutlet.hidden = YES;
cell.fullBtnOutlet.hidden = YES;
}
cell.comboTitle.text =comboItemsArray[indexPath.section].allComboItems[indexPath.row].pName;
return cell;
}