ScrollViewは全画面表示しています。
中身もそれぞれスクリーンサイズです。
問題はポップアップでiPhoneの設定画面に1度飛んでからまたアプリに戻って来ると、
おそらくタブバーの高さ分上にズレてスクロールされてしまいます。
iPhoneの設定画面に飛ばない場合は綺麗にTikTokのようにスクリーンサイズでスクロールされます。
画像下の部分がタブバーの上部に来てしまっている。
本来はスクリーンの下に来ているので青い部分は見えない。
スクロールビューのコンテンツを用意しているコード
swift
1func setupFirebase() { 2 3 let communityXib = UINib(nibName: "CommunityTableViewCell", bundle: Bundle(for: type(of: self))) 4 5 // 描画開始の x,y 位置 6 let px:CGFloat = 0.0 7 var py:CGFloat = 0.0 8 9 var counter = 1 10 11 db.collection("communities").getDocuments() { (querySnapshot, err) in 12 if let err = err { 13 print("Error getting documents: (err)") 14 KRProgressHUD.dismiss()// ローディング終了 15 return 16 } 17 guard querySnapshot!.documents.count > 0 else { 18 KRProgressHUD.dismiss()// ローディング終了 19 return 20 } 21 22 for document in querySnapshot!.documents { 23 print("(document.documentID) => (document.data())") 24 let communityView = communityXib.instantiate(withOwner: self, options: nil).first as! UIView 25 communityView.isUserInteractionEnabled = true 26 27 let community = document.data() 28 let documentId = document.documentID 29 30 // コミュニティー名設定 31 let titleLabel = communityView.viewWithTag(1) as! UILabel 32 let title = community["name"] as! String 33 titleLabel.textColor = UIColor.white 34 titleLabel.text = String(describing: title) 35 // コミュニティー画像設定 36 let img = communityView.viewWithTag(2) as! UIImageView 37 38 39 let storageRef = self.storage.reference() 40 let imgRef: StorageReference! 41 // 新機種 レスポンシブ 42 if UIScreen.main.nativeBounds.height == 2436 || UIScreen.main.nativeBounds.height == 2688 || UIScreen.main.nativeBounds.height == 1792 { 43 imgRef = storageRef.child("communities").child(community["imgX"] as! String) 44 } else { 45 imgRef = storageRef.child("communities").child(community["img8"] as! String) 46 } 47 img.sd_setImage(with: imgRef) 48 img.isUserInteractionEnabled = true 49 img.frame.size.height = UIScreen.main.bounds.height 50 51 let gesture = MyTapGestureRecognizer(target: self, action: #selector(ScrollViewController.btnClick(_:))) 52 gesture.targetString = documentId 53 gesture.targetData = community 54 communityView.addGestureRecognizer(gesture) 55 communityView.tag = 1 56 self.scrollView.addSubview(communityView) 57 58 // 描画開始設定 59 var viewFrame:CGRect = communityView.frame 60 viewFrame.size.width = self.scrollScreenWidth 61 viewFrame.size.height = self.scrollScreenHeight 62 viewFrame.origin = CGPoint(x: px, y: py) 63 communityView.frame = viewFrame 64 65 // 次の描画位置設定 66 py += (self.screenSize.height) 67 counter += 1 68 69 var appGuideViewFrame:CGRect = self.appGuideView.frame 70 appGuideViewFrame.size.width = self.scrollScreenWidth 71 appGuideViewFrame.size.height = self.scrollScreenHeight 72 appGuideViewFrame.origin = CGPoint(x: px, y: py) 73 self.appGuideView.frame = appGuideViewFrame 74 75 // スクロール範囲の設定 76 let nHeight:CGFloat = self.scrollScreenHeight * CGFloat(counter) 77 self.scrollView.contentSize = CGSize(width: self.scrollScreenWidth, height: nHeight) 78 79 } 80 KRProgressHUD.dismiss()// ローディング終了 81 82 } 83 84 }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。