UISearchBar书签图标未隐藏在滚动条上

时间:2019-03-20 10:30:36

标签: ios uinavigationcontroller uinavigationbar uisearchbar uisearchcontroller

我的导航栏中集成了一个action(j_forwardGlobalRequestToLocalOwner, "j", desc="Forward external request to local owner") { peek(requestNetwork_in, RequestMsg) { enqueue( localRequestNetwork_out, RequestMsg, response_latency ) { out_msg.addr := in_msg.addr; out_msg.Type := in_msg.Type; out_msg.Requestor := machineID;// the machineID of the request L2 out_msg.RequestorMachine := MachineType:L2Cache; out_msg.Destination.add(getLocalOwner(cache_entry, in_msg.addr)); out_msg.Type := in_msg.Type; out_msg.MessageSize := MessageSizeType:Forwarded_Control; out_msg.Acks := 0 - 1; } } ,其代码如下:

action(ee_sendDataExclusive, "\e", desc="Send data from cache to requestor, don't keep a shared copy") {
peek(requestNetwork_in, RequestMsg) {
  assert(is_valid(cache_entry));
  if (in_msg.RequestorMachine == MachineType:L2Cache) {
    enqueue(responseNetwork_out, ResponseMsg, request_latency) {
      out_msg.addr := address;
      out_msg.Type := CoherenceResponseType:DATA_EXCLUSIVE;
      out_msg.Sender := machineID;
      out_msg.SenderMachine := MachineType:L1Cache;
      out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache,
          l2_select_low_bit, l2_select_num_bits, intToID(0)));//why do not filled in "in_msg.Requestor"?                              
      out_msg.DataBlk := cache_entry.DataBlk;
      out_msg.Dirty := cache_entry.Dirty;
      out_msg.Acks := in_msg.Acks;
      out_msg.MessageSize := MessageSizeType:Response_Data;
    }
    DPRINTF(RubySlicc, "Sending exclusive data to L2\n");
  }
  else {
    enqueue(responseNetwork_out, ResponseMsg, request_latency) {
      out_msg.addr := address;
      out_msg.Type := CoherenceResponseType:DATA_EXCLUSIVE;
      out_msg.Sender := machineID;
      out_msg.SenderMachine := MachineType:L1Cache;
      out_msg.Destination.add(in_msg.Requestor);
      out_msg.DataBlk := cache_entry.DataBlk;
      out_msg.Dirty := cache_entry.Dirty;
      out_msg.Acks := in_msg.Acks;
      out_msg.MessageSize := MessageSizeType:ResponseLocal_Data;
    }
    DPRINTF(RubySlicc, "Sending exclusive data to L1\n");
  }
}

我还添加了一个这样的自定义书签图标:

UISearchBar

这会在iOS 11.4和12.1.4中产生这种奇怪的外观

enter image description here

似乎文本字段不会剪切图标,也不会应用淡入淡出的动画,例如占位符和搜索图标。

你们看到我这边有什么错误吗? 如果没有,有人可以重现吗? 然后是一个错误,我将提交雷达。

2 个答案:

答案 0 :(得分:1)

好的,我通过以下方法解决了这个问题:

searchController.searchBar.allSubviews.forEach { $0.clipsToBounds = true }

使用此扩展程序获取所有嵌套的子视图:

extension UIView {
    var allSubviews: [UIView] {
        return self.subviews.reduce([UIView]()) { $0 + [$1] + $1.allSubviews }
    }
}

但是这有点hacky,所以其他解决方案值得赞赏:)

答案 1 :(得分:0)

尝试使用clipToBounds代替layoutIfNeeded()

searchController.searchBar.setImage(icon, for: .bookmark, state: .normal)
searchController.searchBar.showsBookmarkButton = true
searchController.searchBar.clipsToBounds = true