Skip to content

Commit

Permalink
[fix] 사진 추가 시 EmptyView 출력되는 문제 해결 (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
trumanfromkorea committed Dec 12, 2022
1 parent 9711df1 commit 6a931df
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ extension KingReceiverWrapper where Base: UIImageView {
}
}

func setImage(with data: Data, placeholder: UIImage? = nil, width: CGFloat, scale: CGFloat = 1) {
guard let image = UIImage.resize(data: data, to: base.frame.size, scale: scale) else {
func setImage(
with data: Data,
placeholder: UIImage? = nil,
to targetSize: CGSize,
scale: CGFloat = 1
) {
guard let image = UIImage.resize(data: data, to: targetSize, scale: scale) else {
base.image = placeholder
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ extension UIImage {
kCGImageSourceCreateThumbnailWithTransform: true,
kCGImageSourceThumbnailMaxPixelSize: maxDimension,
] as CFDictionary

guard let resizedImage = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, resizingOptions) else {
print("resized error")
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ final class CapsuleCreateView: UIView, BaseView {

let titleTextField: ThemeTextField = {
let textField = ThemeTextField(placeholder: "추억하고 싶은 캡슐의 이름을 적어주세요 (최대 15자)")



return textField
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ final class CapsuleCreateViewController: UIViewController, BaseViewController {
setUpNavigation()
addSubViews()
makeConstraints()

mainView.titleTextField.delegate = self

mainView.imageCollectionView.applyDataSource()

addTapGestureRecognizer()
scrollView.addKeyboardNotification()

configure()
bind()
}

Expand All @@ -62,6 +55,13 @@ final class CapsuleCreateViewController: UIViewController, BaseViewController {
scrollView.removeKeyboardNotification()
}

private func configure() {
mainView.titleTextField.delegate = self
mainView.imageCollectionView.applyDataSource()
addTapGestureRecognizer()
scrollView.addKeyboardNotification()
}

func bind() {
closeButton.rx.tap
.withUnretained(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import UIKit
final class AddImageCell: UICollectionViewCell {
let imageView: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFit
imageView.contentMode = .scaleAspectFill

return imageView
}()

override init(frame: CGRect) {
super.init(frame: frame)

backgroundColor = .themeBlack

addSubViews()
makeConstraints()
}
Expand All @@ -31,7 +31,12 @@ final class AddImageCell: UICollectionViewCell {
}

func configure(data: Data) {
imageView.kr.setImage(with: data, placeholder: .empty, width: frame.size.width)
imageView.kr.setImage(
with: data,
placeholder: .empty,
to: frame.size,
scale: FrameResource.openableImageScale
)
}

private func addSubViews() {
Expand Down

0 comments on commit 6a931df

Please sign in to comment.