Tuesday, 15 July 2014

ios - Search Icon Distorted in iPhone 6 Plus - Squashed to an Egg Shape -


I have a search bar in the navigation title view and two buttons in the form of a bar button item. After rotating the device several times, the size of the search icon becomes crushed and the shape becomes like an egg. See the following picture

Enter image details here

Here's a The minimum implementation is that I can get it to reproduce:

  • Create a new project from the template Single View Application

  • go to the main storyboard and embedded in a navigation controller (editor> embed> navigation controller)

  • Replace ViewController.m : @ View Interface Viewer () @ Property (Non-Atomic, Strong) UISearchBar * searchBar; @protecti (nanatomic, strong) UIBarButtonItem * addButton; @property (non-standard, strong) UIBarButtonItem * editButton; @end @implementation ViewController - (zero) viewDidoadload {[Super Viewedload]; // Add a search bar _ searchbar = [[UISAxchangebar] init]; _searchBar.placeholder = @ "Search"; Self.navigationItem.titleView = _searchBar; // Two button Add _addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemAdd goal: self action: nil]; _editButton = [[UIBarButtonItem alloc] initWithTitle: @ "edit" style: UIBarButtonItemStylePlain target: zero operation: zero]; Self.navigationItem.rightBarButtonItems = @ [_ editButton, _addButton]; } @end

  • compile and run it in iPhone 6+ simulator or iPhone 6+ device. Rotate the device several times and you will gradually get corrupted by search icons.

Additional notes:

  • This is only done on iPhone 6 Plus We have tested on many other devices (iPhone 6, with iPhone 5 only) And this is not a problem.
  • If we change the placeholder with UISearchBar with any other string (other than "search"), then we see the distortion Does not. Text after "<">

We actually have the same issue with a distorted UISearchBar icon - only iPhone 6 going on / 7 Plus

for now we have only method to reset the frame of a crazy workaround and icon layoutSubviews of UISearchBar with Swizzling

welcome any better solution Is: - ..)

  Import UIKit Personal var Default Imageviews: CGSize? = Blue Personal Let's Burn: (UISearchBar.Type) - & gt; () = {Original selector in search bar = # selector (searchBar.layoutSubviews) Let's swizzledSelector = #selector (searchBar.proj_layoutSubviews) Basic method = class_getInstanceMethod Give (search byer, original selector) Let's swizzledMethod = class_getInstanceMethod (searchBar, swizzledSelector) method_exchangeEmplementations Law, swizzledMethod)} detail UISearchBar {Open override class func initialize () {// Make sure it is not a sub-class guard === UISearchBar.self else {return} swizzling (self)} // Mark: - method Burning Function, proj_layoutSubviews (Animated: Boole) {self.proj_layoutSubviews (Animated: Animated) Go if imageView = self.g etSearchBarIcon (keeping in mind: self) {if the defaultImageViewSize = defaultImageViewSize {imageView.frame.size = defaultImageViewSize} else {defaultImageViewSize = imageView.frame.size}}} private func getSearchBarIcon (Inwu Views: UIView) - & gt; UIImageView? {For subview in View.subviews {if subview.isMember (K: UIImageView.self), please give imageView = subview as? UIImageView {return imageView} and see if the image vview = getSearchBarIcon (inView: subview) {return imageView}} return blue}}  

No comments:

Post a Comment