我正在METHOD NOT ALLOWED
内构建“用户个人资料”页面,可重用视图的顶部是带有用户图像的from django.views import View
from django.http import HttpResponse
class MessagePassing(View):
def get(self, request, *args, **kwargs):
return HttpResponse("This is GET method")
def post(self, request, *args, **kwargs):
return HttpResponse("This is POST method")
def patch(self, request, *args, **kwargs):
return HttpResponse("This is PATCH method")
def put(self, request, *args, **kwargs):
return HttpResponse("This is PUT method")
。 UICollectionReusableView
已编程(正常工作)在用户图像之间水平滚动。问题是我添加到UIScrollView
的第一张图像(封面图像)被放大了。
下面的代码显示了我的程序实现:
scrollview
添加到ReusableView
scrollview
我尝试过的事情
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
override func awakeFromNib() {
super.awakeFromNib()
}
private let scrollView: UIScrollView = {
let view = UIScrollView()
view.contentMode = .scaleAspectFit
view.isUserInteractionEnabled = true
view.backgroundColor = UIColor(hexString: COLLECTION_VIEW_BACKGROUND_COLOR)!
view.isScrollEnabled = true
view.alwaysBounceHorizontal = true
view.translatesAutoresizingMaskIntoConstraints = false
view.isPagingEnabled = true
return view
}()
private var coverImage: UIImageView = {
let view = UIImageView()
view.contentMode = .scaleAspectFill
view.isUserInteractionEnabled = true
view.translatesAutoresizingMaskIntoConstraints = false
view.clipsToBounds = true
return view
}()
中的private func setupView() {
backgroundColor = UIColor.white
// ScrollView delegate
scrollView.delegate = self
// Scroll View Init
addSubview(scrollView)
scrollView.topAnchor.constraint(equalTo: self.topAnchor, constant: 0).isActive = true
scrollView.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 0).isActive = true
scrollView.rightAnchor.constraint(equalTo: self.rightAnchor, constant: 0).isActive = true
scrollView.heightAnchor.constraint(equalToConstant: 350).isActive = true
scrollView.contentSize = CGSize(width: self.frame.size.width, height: 350)
// Cover Image init
scrollView.addSubview(coverImage)
coverImage.frame = scrollView.frame
}
,ZoomScale
,ZoomMin
。ZoomMax
之后设置ScrollView
的{{1}}。contentSize
和scrollView
(。ImageView
等)中的contentMode
ImageView
添加为ScrollView
的子视图scaleAspectFit
,一次只调用一个Init方法更改ImageView
的{{1}}并尝试多种将其锚定到视图的方法
我仅从第4点和第6点看到了明显的变化,但没有任何变化。我还查看了该站点上在ScrollView
中存在类似问题的其他答案,但是所有解决方案均无效。
在我使用情节提要时,请先感谢任何可以提供帮助的人,此问题并未发生。