Post not yet marked as solved
My project works fine on one MacBook, but after I transfering it to another MacBook, it crashes.Here is a part of my code:func MusicPlay()
{
Playnow = true
self.ipv.start()
self.playButton.isHidden = true
self.pauseButton.isHidden = false
var path = Bundle.main.path(forResource:music!,ofType :"mp3")
if Initial == true{
path = Bundle.main.path(forResource:music!,ofType :"mp3")
}
else{
switch music {
case "Viva La Vida":
path = Bundle.main.path(forResource:"result1",ofType :"mp3")
case "Something Just Like This":
path = Bundle.main.path(forResource:"result2",ofType :"mp3")
case "Señorita":
path = Bundle.main.path(forResource:"result3",ofType :"mp3")
default:
path = Bundle.main.path(forResource:music!,ofType :"mp3")
}
}
let soundUr1 = URL(fileURLWithPath: path!)
do{
try audioPlayer = AVAudioPlayer(contentsOf: soundUr1)
audioPlayer.volume = 1.0
audioPlayer.numberOfLoops = -1
audioPlayer.delegate = self
audioPlayer.play()
} catch{
print(error)
}
}After choosing a music at tableView, it performs the function "MusicPlay",and then the project crashes at line 26:try audioPlayer = AVAudioPlayer(contentsOf: soundUr1)Error message:2020-02-15 22:47:22.013016+0800 InteractivePlayerView[6645:253620] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x6000004d7120> F8BB1C28-BAE8-11D6-9C31-00039315CD46What should I do to address this problem?
Post not yet marked as solved
When I run my project,it crashes quickly,with error message:"Unknown class _TtC10Soul_Music27CollectionViewSlantedLayout in Interface Builder file.""Soul_Music" is the name of my project and "CollectionViewSlantedLayout" is a class at my project.I'm sure that there is no class called "_TtC10Soul_Music27CollectionViewSlantedLayout".How to address this problem?Thanks in advance.
I am working on show weather project. I am listing the cities from database. When I click on a city, another viewcontroller should open. But when I click on a city, the didSelectRowAtIndexPath function does not work.Here is the my code:import UIKit
import SCLAlertView
import Popover
class UserInfoViewController: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate{
fileprivate var texts = ["Los Angeles", "New York", "Chicago"]
fileprivate var popover: Popover!
fileprivate var popoverOptions: [PopoverOption] = [
.type(.auto),
.blackOverlayColor(UIColor(white: 0.0, alpha: 0.6))
]
@IBOutlet var compositionNum: UILabel!
@IBOutlet var fans: UILabel!
@IBOutlet var location: UILabel!
@IBOutlet var userName: UILabel!
@IBOutlet var userImag: UIImageView!
@IBOutlet var imagBt: UIButton!
@IBAction func modifyInfo(_ sender: Any) {
let alert = SCLAlertView()
let textField1 = alert.addTextField(userName.text)
let textField2 = alert.addTextField(location.text)
alert.addButton(“Done”)
}
}
@IBOutlet var topButton: UIButton!
@IBAction func expandSet(_ sender: Any) {
self.popover = Popover(options: self.popoverOptions)
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width-250, height: 120))
tableView.delegate = self
tableView.dataSource = self
tableView.isScrollEnabled = false
tableView.allowsSelection = true
self.popover.show(tableView, fromView: self.topButton)
}
@IBAction func modifyImag(_ sender: Any) {
showBottomAlert()
}
override func viewDidLoad() {
super.viewDidLoad()
view.bringSubviewToFront(userImag)
view.bringSubviewToFront(imagBt)
}
func photos() {
self.showBottomAlert()
}
func showBottomAlert(){
let alert = SCLAlertView()
}
func goCamera(){
if UIImagePickerController.isSourceTypeAvailable(.camera){
let cameraPicker = UIImagePickerController()
cameraPicker.delegate = self
cameraPicker.allowsEditing = true
cameraPicker.sourceType = .camera
self.present(cameraPicker, animated: true, completion: nil)
} else {
SCLAlertView().showError("",subTitle: "",closeButtonTitle: "")
}
}
func goImage(){
let photoPicker = UIImagePickerController()
photoPicker.delegate = self
photoPicker.allowsEditing = true
photoPicker.sourceType = .photoLibrary
self.present(photoPicker, animated: true, completion: nil)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let image : UIImage = info[UIImagePickerController.InfoKey.editedImage] as! UIImage
userImag.image = image
userImag.layer.cornerRadius = userImag.frame.size.width / 2
self.dismiss(animated: true, completion: nil)
}
}
extension String{
var isBlank:Bool{
return allSatisfy({$0.isWhitespace})
}
}
extension UserInfoViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.popover.dismiss()
}
}
extension UserInfoViewController: UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
cell.textLabel?.text = self.texts[(indexPath as NSIndexPath).row]
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAtIndexPath indexPath: IndexPath) {
if(indexPath.row == 0){
let storyboard = UIStoryboard(name: "Main", bundle: nil)
guard let secondVC = storyboard.instantiateViewController(withIdentifier: "Main") as? MainViewController else { return }
self.present(secondVC, animated: true, completion: nil)
}
else if(indexPath.row == 1){
}
else{
}
}
}What should I do to make it correct?Thanks in advance.
Post not yet marked as solved
My project can normally work until I update the Xcode to Version 11.0 (11A420a).Now,When it runs in a little while,it crashes.The error message is as follows:dyld: Symbol not found: _OBJC_CLASS_$__TtCs12_SwiftObject Referenced from: /Users/qizijia/Library/Developer/CoreSimulator/Devices/8B40226A-A7D4-4915-9982-9C8CEF77F24B/data/Containers/Bundle/Application/4B75826C-5FEE-4EB3-85EE-23477B0ED2BD/IRIS iOS.app/Frameworks/SCLAlertView.framework/SCLAlertView Expected in: /Library/Developer/Toolchains/swift-5.0.1-RELEASE.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCore.dylibin /Users/qizijia/Library/Developer/CoreSimulator/Devices/8B40226A-A7D4-4915-9982-9C8CEF77F24B/data/Containers/Bundle/Application/4B75826C-5FEE-4EB3-85EE-23477B0ED2BD/IRIS iOS.app/Frameworks/SCLAlertView.framework/SCLAlertViewWhat can I do to address the problem?Thanks in advance.
Post not yet marked as solved
Hey,This is a part of my code:SecondViewController.swiftimport UIKit
class DemoViewController: ExpandingViewController {
typealias ItemInfo = (imageName: String, title: String)
fileprivate var cellsIsOpen = [Bool]()
fileprivate let items: [ItemInfo] = [("item0", "Boston"), ("item1", "New York"), ("item2", "San Francisco"), ("item3", "Washington")]
@IBOutlet var pageLabel: UILabel!
}
extension DemoViewController{
override func viewDidLoad() {
itemSize = CGSize(width: 256, height: 460)
super.viewDidLoad()
registerCell()
fillCellIsOpenArray()
addGesture(to: collectionView!)
configureNavBar()
}
}
extension DemoViewController {
fileprivate func registerCell() {
let nib = UINib(nibName: String(describing: UICollectionViewCell.self), bundle: nil)
collectionView?.register(nib, forCellWithReuseIdentifier: String(describing: UICollectionViewCell.self))
}
fileprivate func fillCellIsOpenArray() {
cellsIsOpen = Array(repeating: false, count: items.count)
}
fileprivate func getViewController() -> ExpandingTableViewController {
let storyboard = UIStoryboard(storyboard: .Main)
let toViewController: DemoTableViewController = storyboard.instantiateViewController()
return toViewController
}
fileprivate func configureNavBar() {
navigationItem.leftBarButtonItem?.image = navigationItem.leftBarButtonItem?.image!.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
}
}
/// MARK: Gesture
extension DemoViewController {
fileprivate func addGesture(to view: UIView) {
let upGesture = Init(UISwipeGestureRecognizer(target: self, action: #selector(DemoViewController.swipeHandler(_:)))) {
$0.direction = .up
}
let downGesture = Init(UISwipeGestureRecognizer(target: self, action: #selector(DemoViewController.swipeHandler(_:)))) {
$0.direction = .down
}
view.addGestureRecognizer(upGesture)
view.addGestureRecognizer(downGesture)
}
@objc func swipeHandler(_ sender: UISwipeGestureRecognizer) {
let indexPath = IndexPath(row: currentIndex, section: 0)
guard let cell = collectionView?.cellForItem(at: indexPath) as? DemoCollectionViewCell else { return }
// double swipe Up transition
if cell.isOpened == true && sender.direction == .up {
pushToViewController(getViewController())
if let rightButton = navigationItem.rightBarButtonItem as? AnimatingBarButton {
rightButton.animationSelected(true)
}
}
let open = sender.direction == .up ? true : false
cell.cellIsOpen(open)
cellsIsOpen[indexPath.row] = cell.isOpened
}
}
// MARK: UIScrollViewDelegate
extension DemoViewController {
func scrollViewDidScroll(_: UIScrollView) {
pageLabel.text = "\(currentIndex + 1)/\(items.count)"
}
}
// MARK: UICollectionViewDataSource
extension DemoViewController {
override func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
super.collectionView(collectionView, willDisplay: cell, forItemAt: indexPath)
guard let cell = cell as? DemoCollectionViewCell else { return }
let index = indexPath.row % items.count
let info = items[index]
cell.backgroundImageView?.image = UIImage(named: info.imageName)
cell.customTitle.text = info.title
cell.cellIsOpen(cellsIsOpen[index], animated: false)
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let cell = collectionView.cellForItem(at: indexPath) as? DemoCollectionViewCell
, currentIndex == indexPath.row else { return }
if cell.isOpened == false {
cell.cellIsOpen(true)
} else {
pushToViewController(getViewController())
if let rightButton = navigationItem.rightBarButtonItem as? AnimatingBarButton {
rightButton.animationSelected(true)
}
}
}
}
// MARK: UICollectionViewDataSource
extension DemoViewController {
override func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int {
return items.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
return collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: DemoCollectionViewCell.self), for: indexPath)
}
}TableViewController.swiftimport UIKit
/// Base class for UITableViewcontroller which have back transition method
open class ExpandingTableViewController: UITableViewController {
// MARK: Vars
/// The height of the table view header, set before transition
open var headerHeight: CGFloat = 236
var transitionDriver: TransitionDriver?
}
// MARK: Helpers
extension ExpandingTableViewController {
fileprivate func getScreen() -> UIImage? {
let height = (headerHeight - tableView.contentOffset.y) < 0 ? 0 : (headerHeight - tableView.contentOffset.y)
let backImageSize = CGSize(width: view.bounds.width, height: view.bounds.height - height + getTabBarHeight())
let backImageOrigin = CGPoint(x: 0, y: height + tableView.contentOffset.y)
return view.takeSnapshot(CGRect(origin: backImageOrigin, size: backImageSize))
}
fileprivate func getTabBarHeight() -> CGFloat {
guard let navigationController = self.navigationController else {
return 0
}
let insets = automaticallyAdjustsScrollViewInsets
let tabBarHeight = insets == true ? navigationController.navigationBar.frame.size.height : 0
let stausBarHeight = insets == true ? UIApplication.shared.statusBarFrame.size.height : 0
return tabBarHeight + stausBarHeight
}
}
// MARK: Methods
extension ExpandingTableViewController {
/**
Pops the top view controller from the navigation stack and updates the display with custom animation.
*/
public func popTransitionAnimation() {
guard let transitionDriver = self.transitionDriver else {
return
}
let backImage = getScreen()
var offset = tableView.contentOffset.y > headerHeight ? headerHeight : tableView.contentOffset.y
offset += getTabBarHeight()
transitionDriver.popTransitionAnimationContantOffset(offset, backImage: backImage)
_ = navigationController?.popViewController(animated: false)
}
}There is an error in SecondViewController.swift at the line 37 :return toViewControllerAnd the error message is "Cannot convert return expression of type 'DemoTableViewController' to return type 'ExpandingTableViewController' "What should I do to make it right?Thanks.