首页 \ 问答 \ 防止在UITableViewCell内重新加载MKMapView(Prevent reloading of MKMapView inside UITableViewCell)

防止在UITableViewCell内重新加载MKMapView(Prevent reloading of MKMapView inside UITableViewCell)

我已经创建了UITableViewCell的子类并添加了MapView。 每当我滚动屏幕的地图并滚动回那个单元格时,它会再次加载。 (众所周知,这是细胞重用的默认行为)

反正有没有阻止它? 或者你知道那种情况的其他技巧吗? 非常感谢!


I've made a subclass of UITableViewCell and added a MapView. Everytime I scroll the map of the screen and scroll back to that cell it loads again. (As you all know it's the default behaviour for cell reusing)

Is there anyway to prevent that? Or do you know any other tricks for that case? thanks a lot!


原文:https://stackoverflow.com/questions/7987346
更新时间:2022-06-05 19:06

最满意答案

std::priority_queue的默认构造函数实际上是可选参数:

explicit priority_queue(const Compare& x = Compare(), Container&& = Container());

您将注意到第一个参数是比较器类的实例。

首先构造您的比较器类,使其以任何方便的方式引用您的hashmap,然后使用比较器类来构造您的优先级队列。


std::priority_queue's default constructor actually takes optional parameters:

explicit priority_queue(const Compare& x = Compare(), Container&& = Container());

You will note that the first parameter is an instance of the comparator class.

Construct your comparator class first, making it reference your hashmap in whatever way is convenient for you, then use the comparator class to construct your priority queue.

相关问答

更多
  • 这是可能的,但我真的不推荐它。 主要问题是: 除非您准备编写引用计数包装器代码(使用C ++),否则C ++容器无法容纳Python对象(例如memoryviews) 你可以得到一个C指针指向memoryview的第一个元素,但是: 您必须确保保留对基础对象(拥有内存)的引用,否则Python将释放它,并且您将使用访问无效内存。 一个指针会丢失有关数组有多长的所有信息。 你可以使用的比较器非常有限(它们必须可以表达为一个cdef函数) - 例如我写了一个比较数组第二个元素的例子,但是需要重新编译才能比较第三 ...
  • 正如其他人暗示没有太多解释,问题是你的比较功能: def compare(that: Offer) = this.interestRate.compareTo(that.interestRate) 这匹配数字的自然排序,其中-1 <0 <1。 在Scala中创建优先级队列时,它使用从您定义的Order隐式派生的Order 。 您缺少的是优先级队列将“较高”值视为具有最高优先级(基本上它按降序排序)。 最简单的解决方法是将compare函数更改为其反函数: def compare(that: Offer) ...
  • 使比较类型上的函数模板化。 template void some_processing( std::priority_queue, std::vector>, CompT> & nodes) { // something being done with the queue } ...
  • 模板参数是比较器的类型 。 您仍然需要将比较器的实例传递给priority_queue构造函数,这时您可以使用您喜欢的任何参数构造比较器实例。 例如: map m; edgeCompare comp(m); priority_queue, edgeCompare> pq(comp); 您还可edgeCompare联创建edgeCompare对象,但消除歧义需要额外的括号: priority_queue
  • prioq prio; 使用默认构造的比较器(在您的情况下为comp类型)构造一个优先级队列。 这意味着内部存储的指向比较函数的指针实际上是用零初始化的。 比较器(如果默认构造的一个是不够的)可以初始化为作为构造函数的参数传递的值: prioq prio(&comparator); // ~~~~~~~~~~^ prioq prio; constructs a priority queue with a default-constructed comparator (of type com ...
  • 我认为这不是一个强硬的原因。 没有根本原因你不能这样做 - 通过这样做来添加是微不足道的: public PriorityQueue(`Comparator comparator) { this(/* reasonable default */, comparator); } 我的猜测是,这是对设计的疏忽。 正如@Sotirios Delimanolis在评论中指出的那样,在Java 8中将添加这个构造函数。 希望这可以帮助! I don't think there's a ...
  • std::priority_queue的默认构造函数实际上是可选参数: explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); 您将注意到第一个参数是比较器类的实例。 首先构造您的比较器类,使其以任何方便的方式引用您的hashmap,然后使用比较器类来构造您的优先级队列。 std::priority_queue's default constructor actually takes optiona ...
  • 这个问题被称为最令人烦恼的解析。 priority_queue, vector>, MyComparator> minHeap(MyComparator(arrays)); 这里,编译器无法确定这是函数签名还是构造函数的调用。 摆脱这种歧义的通常方法是添加一对额外的括号: priority_queue, vector>, MyComparator> minHeap((MyComparat ...
  • 这可能有效: std::priority_queue, boost::function > 然后将你的绑定表达式传递给队列的构造函数。 PS你会得到那些编译错误,因为你在运行时评估的表达式需要一个类型名或常量表达式。 This could work: std::priority_queue, boost::function > Then ...
  • 在STL容器中使用的比较对象以及在STL算法中使用的谓词必须是可复制的对象,方法和algorthims可以随意复制这些函数,但是他们希望这样做。 这意味着如果您的比较对象包含状态,则必须正确复制此状态,因此您可能需要提供合适的复制构造函数和复制赋值运算符。 如果您希望比较对象包含可变状态,则问题会更复杂,因为比较对象的任何副本都需要共享可变状态。 如果您可以将状态维护为单独的对象,那么您可以让比较对象保持指向此外部状态的指针; 如果没有,你可能会发现你需要共同拥有共同状态所以你可能需要像tr1::share ...

相关文章

更多

最新问答

更多
  • 您如何使用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)