首页 \ 问答 \ 将项目标记为TableView中新添加的项目(Marking an item as newly added in TableView)

将项目标记为TableView中新添加的项目(Marking an item as newly added in TableView)

我有一个UITableView,只需按一下按钮即可添加新项目。 我想强调这个新添加的项目。 由于UITableView是数据驱动的并且单元格是循环使用的,所以我能想到的唯一方法来标记这个新添加的项目是在数据本身中添加BOOL标志,然后突出显示单元格并在第一次遇到时取消标记。

有没有其他方法可以做到这一点,而不必污染数据源?


I have a UITableView where I can add a new item with a touch of a button. I would like to highlight this newly added item. Since UITableView is data-driven and cells are recycled, the only way I can think of so far to mark this newly added item is to add a BOOL flag in the data itself, then highlight the cell and negate the flag on first encounter.

Is there another way of doing this without having to contaminate the data source?


原文:https://stackoverflow.com/questions/8360628
更新时间:2023-08-24 18:08

最满意答案

通常在WHEN-VALIDATE-ITEM上使用GO_BLOCKGO_ITEM是有限制的。 然而,有几种方法可以解决这个问题。 一种方法是使用WHEN-TIMER-EXPIRED触发器。 这里是如何 -

WHEN-TIMER-EXPIRED

Begin    
if GET_APPLICATION_PROPERTY(TIMER_NAME) = 'NEW_TIMER' then    
   CALL_PROG_UNIT(); --This is your Procedure that calls the GO_BLOCK   
   /*Do rest of validation here*/
end if;
END;

WHEN-VALIDATE-ITEM

DECLARE    
  timer_id TIMER;    
Begin        
  timer_id := CREATE_TIMER('NEW_TIMER',1,NO_REPEAT);    --set a short timer so that the WHEN-TIMER-EXPIRED trigger is fired immediately
End;

会发生什么 - 一旦调用CREATE_TIMER函数,这将创建&到期计时器,然后表单级触发器WHEN-TIMER-EXPIRED将检查过期的计时器名称并调用具有GO_BLOCK程序单元。 希望这可以帮助。


UPDATE

Jeffery Kemp先生希望看到证明这个解决方案有效。 所以在这里 -

一个带有两个块BLOCK1BLOCK2的Oracle表单,其中包含文本项

在这里输入图像描述

WVI触发器

在这里输入图像描述

WTE表格触发器。 这将首先调用带有GO_BLOCK函数调用的PROGRAM UNIT P_CALL_PROC ,然后对字段Number 2一些验证。

在这里输入图像描述

这是P_CALL_PROC

在这里输入图像描述

这里是结果 -

在这里输入图像描述

在这里输入图像描述

是一个Youtube链接,用于查看表单的实际效果。


Usually there is a restriction on using GO_BLOCK or GO_ITEM on a WHEN-VALIDATE-ITEM. However there are a couple of ways to overcome this. One way is to use a WHEN-TIMER-EXPIRED trigger. Here is how-

WHEN-TIMER-EXPIRED

Begin    
if GET_APPLICATION_PROPERTY(TIMER_NAME) = 'NEW_TIMER' then    
   CALL_PROG_UNIT(); --This is your Procedure that calls the GO_BLOCK   
   /*Do rest of validation here*/
end if;
END;

WHEN-VALIDATE-ITEM

DECLARE    
  timer_id TIMER;    
Begin        
  timer_id := CREATE_TIMER('NEW_TIMER',1,NO_REPEAT);    --set a short timer so that the WHEN-TIMER-EXPIRED trigger is fired immediately
End;

What happens is - This will create & expire the timer as soon as the CREATE_TIMER function is called and then the form level trigger WHEN-TIMER-EXPIRED will check the expired timer name and call your program unit that has the GO_BLOCK. Hope this helps.


UPDATE

Mr Jeffery Kemp wanted to see proof that this solution works. So here it is-

An Oracle form with two Blocks BLOCK1 and BLOCK2 with text items on it

enter image description here

W-V-I Trigger

enter image description here

W-T-E Form Trigger. This calls a PROGRAM UNIT P_CALL_PROC with GO_BLOCK function call first and then does some validations on the field Number 2.

enter image description here

Here is P_CALL_PROC

enter image description here

And here is the result-

enter image description here

And

enter image description here

Here is a Youtube link to see the Form in action.

相关问答

更多
  • 它不起作用的原因是因为你正在构造一个字符串,然后将它与一个整数进行比较。 结果转换失败。 字符串包含看起来像SQL的东西,实际上并不执行它。 相反,您需要执行查询,例如使用EXISTS : SET TERM ^ ; CREATE TRIGGER STOP_PREMIX_INSERT_PRODUCEDD FOR PRODUCEDD ACTIVE BEFORE INSERT OR UPDATE POSITION 0 AS BEGIN IF (EXISTS (SELECT * ...
  • 您可以在触发器中捕获验证错误: try { upsert financeRecord; } catch (Exception e) { // do whatever you'd like to on an exception here } You could catch the validation error in your trigger: try { upsert financeRecord; } catch (Exception e) { // do whateve ...
  • 只有在创建模型之前定义钩子时钩子才有效: var userSchema = new Schema({...}); userSchema.pre('save', function(next){ // tried with pre('validate') console.log('triggered...'); next(); }); var User = module.exports = mongoose.model('User', userSchema); Hooks only wor ...
  • 这是一个使用cat_tools中的trigger__parse函数的示例 ,您可以使用pgxnclient安装该函数 。 首先,一些一般设置: CREATE EXTENSION cat_tools; CREATE TABLE i(i int); 创建实际的事件触发器: CREATE OR REPLACE FUNCTION no_before_triggers() RETURNS event_trigger LANGUAGE plpgsql AS $body$ DECLARE r record; BEG ...
  • 问题是你的TRIGGER正在处理你提出的EXCEPTION ,但它并没有传递给触发它的DML。 因此, RentalType列正常插入。 因此,要么删除 EXCEPTION块,要么在EXCEPTION 添加一个简单的RAISE语句 另外,看起来像 :NEW.RentalType != 'M' OR :NEW.RentalType != 'B' 将永远是真实的。 你的意思是:NEW.RentalType != 'M' AND :NEW.RentalType != 'B' ? The problem is t ...
  • 因为您正在使用,所以会出现该错误. 而不是->在表达式NEW.data.ids提取ids数组。 但是你的触发器无论如何不会工作,因为你不是想避免遏制,而是重叠在数组中。 您可以编写触发器函数的一种方法是: CREATE OR REPLACE FUNCTION validate_id_constraint() RETURNS trigger LANGUAGE plpgsql AS $$DECLARE j jsonb; BEGIN FOR j IN SELECT jsonb_arr ...
  • 您可以将insert更改为以下内容,以检查是否已存在重复项。 select假定my_hist的主键是id和start_date ,将where not exists子句更改为仅使用主键值(如果它们不同)。 insert into my_hist select :old.id, :old.no, :old.start_date, :old.end_date, sysdate from dual where not exists ( select 1 from ...
  • 通常在WHEN-VALIDATE-ITEM上使用GO_BLOCK或GO_ITEM是有限制的。 然而,有几种方法可以解决这个问题。 一种方法是使用WHEN-TIMER-EXPIRED触发器。 这里是如何 - WHEN-TIMER-EXPIRED Begin if GET_APPLICATION_PROPERTY(TIMER_NAME) = 'NEW_TIMER' then CALL_PROG_UNIT(); --This is your Procedure that calls the ...
  • 我不确定我是否理解你。 如果需要从其他表中显示原因名称,则POST-QUERY触发器是正确的,但是在DISPLAY_COMM_DET块上。 将此块作为基于CUST_COMM表的详细块。 创建非数据库项NDB_COMM_REASON_VALUE。 在DISPLAY_COMM_DET块上创建POST-QUERY触发器,如下所示: declare cursor c_reason is select comm_value from common_master where comm ...
  • 看看名为SQL Search的免费 Red-Gate工具,它可以执行此操作 - 它会在整个数据库中搜索任何类型的字符串。 在您的情况下:搜索您已删除的列,并让SQL搜索找到引用该列的所有存储过程,触发器等 - >为您提供需要修复的那些事项的简单列表。 对于任何DBA或数据库开发人员来说,这是一个非常必备的工具 - 我是否已经提到它可以完全免费用于任何类型的使用? Have a look at the FREE Red-Gate tool called SQL Search which does this - ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)