xamarin - 自定义渲染器中的 e.OldElement 和 e.NewElement
问题描述
这里微软告诉我们在自定义渲染器中使用e.OldElement
和:e.NewElement
...为防止内存泄漏,在实例化新的本机控件时必须小心...
...
if (e.OldElement != null) { // Unsubscribe from event handlers and cleanup any resources } if (e.NewElement != null) { // Configure the control and subscribe to event handlers }
另一方面,他们在这里忽略了自己的建议:
if (Control != null) { // do whatever you want to the UITextField here! Control.BackgroundColor = UIColor.FromRGB (204, 153, 255); Control.BorderStyle = UITextBorderStyle.Line; }
那么我们是否需要担心它们?还是取决于情况(因此:哪个在哪里?)?
解决方案
推荐阅读
- java - 改进计算余数的递归
- php - 我想同时使用两个数组值,例如 arr1[0] 和 arr2[0] 值,这些数组的长度在 php 中是相同的
- python - 如何使用 python boto3 更新 s3 中的 json?
- java - Java Play Framework 1.4x - 开发服务器
- git - git discard 专门更改暂存区
- cmake - 无论如何在CMake中动态查找库路径?
- html - 页面或视频上的简单密码字段
- javascript - 在 localeCompare() 方法中使用 locale 选项
- wpf - 如何将图像的平移限制在范围内
- compression - 压缩具有相似内容的 ISO 文件集合