2017-10-06 1 views
2

내 탐색 모음 항목에 대한 사용자 정의보기로 일반 이미지보기를하고 있어요하지만 그것이 무슨 일이 일어나고 있는지입니다 : 이것은탐색 모음 사용자 정의 이미지보기 문제 11

let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 34, height: 34)) 
imageView.kf.setImage(with: user.profilePictureURL) 
if user.profilePictureURL == nil { 
    imageView.image = #imageLiteral(resourceName: "ProfilePlaceholderSuit") 
} 
imageView.backgroundColor = .white 
imageView.layer.masksToBounds = true 
imageView.layer.cornerRadius = 17 
imageView.layer.borderWidth = 1 
imageView.layer.borderColor = UIColor.white.cgColor 
imageView.isUserInteractionEnabled = true 
imageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap))) 
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: imageView) 
print("ok, so the image view frame is", imageView.frame) // 0, 0, 34, 34 

enter image description here

답변

1

이 유형을했다.

오른쪽 상단의 barButton 항목에 프로필 이미지를 설정하려는 경우 please check my answer.. 당신이 킹 피셔 프레임 워크에 문제가 아니에요

let widthConstraint = imageView.widthAnchor.constraint(equalToConstant: 34) 
    let heightConstraint = imageView.heightAnchor.constraint(equalToConstant: 34) 
    heightConstraint.isActive = true 
    widthConstraint.isActive = true 
0

했다 Kingfisher 프레임 워크의 문제점. 나는 SDWebImage로 전환했으며 잘 작동합니다 (때로는).

편집 :

이 대신 프레임의 자동 레이아웃을 사용하기 때문에 아이폰 OS 11 UIBarButtonItem의 많은 개발자들이 직면 한 문제의

let imageView = UIImageView() 
imageView.translatesAutoresizingMaskIntoConstraints = false 
imageView.heightAnchor.constraint(equalToConstant: 34).isActive = true 
imageView.widthAnchor.constraint(equalToConstant: 34).isActive = true 
+1

아래 없음처럼 코드에 이미지 뷰의 제약 조건을 추가 할 수 없습니다 현명한

다른, 당신이 대신 프레임 – iPatel

+0

감사의 자동 레이아웃 사용해야 아이폰 OS (11)의 문제입니다 @iPatel . 이미지 뷰를 탐색 막대로 제한하거나 높이와 너비 만 설정해야합니까? – Cesare

+0

그게 @iPatel 작동합니다. 언제든지 대답으로 게시 할 수 있습니다. – Cesare

관련 문제