I'm using the following library:
https://github.com/lukabernardi/LBBlurredImage
This is the code I'm using to blur my background image that I'm adding to a ViewController:
var background = UIImage(named: "bg")
var backgroundImageView = UIImageView(image: background)
backgroundImageView.contentMode = .ScaleAspectFill;
backgroundImageView.setImageToBlur(background, blurRadius: 10, completionBlock: { () -> Void in
println("The blurred image has been set")
})
self.view.addSubview(backgroundImageView)
I'm getting the following error and I'm not sure why:
-[UIImageView setImageToBlur:blurRadius:completionBlock:]: unrecognized selector sent to instance 0x7ff08a802390
2015-01-27 10:50:44.326 TestApp[9289:66346] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setImageToBlur:blurRadius:completionBlock:]: unrecognized selector sent to instance 0x7ff08a802390'
UPDATE:
Looks like I'm not the only one to receive the error.
Exception was that the image I was passing was nil and in turn it was violating NSParameterAssert(image);
var background = UIImage(named: "bg")
Instead of this try to specify the full path of the image.
It worked for me and I am pretty sure it will work for you too.
You can also try this path with your code
var background = UIImage(named: "Images/bg");
Related
I'm trying to embed an youtube video in swiftUI app (building for iOS 14)
i'm using CocoaPods with the following Podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '14.0'
target 'TestProjectYoutube' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for TestProjectYoutube
pod 'Alamofire', '~> 5.0'
pod 'SwiftyJSON', '~> 4.0'
pod 'URLImage'
pod 'Introspect'
end
I've created the following view
import SwiftUI
import CoreData
struct ContentView: View {
#Environment(\.managedObjectContext) private var viewContext
var body: some View {
VStack() {
VideoView(videoID: "CX-BdDHW0Ho")
}
}
}
struct VideoView: UIViewRepresentable {
let videoID: String
func makeUIView(context: Context) -> WKWebView {
let webView = WKWebView(frame: CGRect(x: 0.0, y: 0.0, width: 0.1, height: 0.1))
return webView
}
func updateUIView(_ uiView: WKWebView, context: Context) {
guard let youtubeURL = URL(string: "https://www.youtube.com/embed/\(videoID)") else { return }
uiView.scrollView.isScrollEnabled = false
uiView.load(URLRequest(url: youtubeURL))
}
}
The error i got is:
2023-01-16 15:35:16.130698+0100 app[44720:3273388] -[__NSArrayM length]: unrecognized selector sent to instance 0x2824115c0
2023-01-16 15:35:16.130920+0100 app[44720:3273388] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM length]: unrecognized selector sent to instance 0x2824115c0'
*** First throw call stack:
(0x18048bc80 0x197cb1ee4 0x18055c708 0x18042556c 0x18042477c 0x18ac78644 0x18e74ce50 0x18e9d0ca4 0x18e9d0888 0x18e94c418 0x18e963de0 0x18ecdd224 0x18ecdcec8 0x18e72b69c 0x18e727c4c 0x18e72cd18 0x18ac73590 0x18ac7410c 0x1804ac468 0x1804bc598 0x1803fe774 0x180403e48 0x180417194 0x1a0f56988 0x182c1aa88 0x1829b3fc8 0x187c6cd68 0x187bb783c 0x187b9d1dc 0x10281f3fc 0x10281f530 0x102ff84d0)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM length]: unrecognized selector sent to instance 0x2824115c0'
terminating with uncaught exception of type NSException
When I replace the youtube.com with google.com, i dont get the error and google is loaded.
Can someone help me with this?
I'm creating an app that users AVFoundation to record a video. I have a Login View Contoller which leads to a View Controller (user can see their profile details here) which leads to a Data Collection View Controller (this is where the video camera is presented). All works fine but when I click on a back button to go back to the View Controller, and then click 'start data collection' to go back into the video camera a 2nd time, the app crashes.
Crash info:
2018-08-11 11:39:51.861569+0100 LiopaDatacapture-iOS[6343:1642808] *
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '* -[AVCaptureMetadataOutput
setMetadataObjectTypes:] Unsupported type found - use
-availableMetadataObjectTypes'
*** First throw call stack: (0x1842e6d8c 0x1834a05ec 0x189e54b44 0x10128f4fc 0x1012989a4 0x101298ca4 0x18df01e64 0x18df01a50
0x18eaa4fd8 0x18e12b398 0x18e12a25c 0x18e3a33a0 0x18e0e13e4
0x18e1297bc 0x18e129654 0x18e3a6350 0x18e734d24 0x18e881af4
0x18e8819a0 0x18e39a49c 0x101297f5c 0x18e05564c 0x18e176870
0x18e05b700 0x18e1911a8 0x18e0d89e0 0x18e0cd890 0x18e0cc1d0
0x18e8add1c 0x18e8b02c8 0x18e8a9368 0x18428f404 0x18428ec2c
0x18428c79c 0x1841acda8 0x186192020 0x18e1cc758 0x101284a90
0x183c3dfc0) libc++abi.dylib: terminating with uncaught exception of
type NSException (lldb)
I'm using AVCaptureMetadataOutput to detect faces. This code is in my SessionHandler class where the video camera is being set up.
// define metadata
let metaOutput = AVCaptureMetadataOutput()
if cameraSession.canAddOutput(metaOutput) {
metaOutput.setMetadataObjectsDelegate(self, queue: faceQueue)
cameraSession.addOutput(metaOutput)
print("metaoutput added")
}
// set metadata to look for faces
metaOutput.metadataObjectTypes = [AVMetadataObject.ObjectType.face]
In my DataCaptureViewController.swift file this is where I load the video camera-
override func viewDidLoad() {
super.viewDidLoad()
sessionHandler.setupCamera()
audioRecorder.setUpAudioSession()
createObservers()
let layer = sessionHandler.layer
layer.frame = previewView.bounds
previewView.layer.addSublayer(layer)
view.layoutIfNeeded()
jsonSentence.text = "Press start button to get phrase"
startButton.setTitle("Start", for: .normal)
}
I've played around a bit trying viewDidAppear and viewWillAppear but I'm new to swift and don't think I fully understand what they do or if this is what's causing the problem.
The SessionHandler class variables need to be shared with an Objective-C class so I've created a shared instance of it to be used throughout the app.
static let sharedSession = SessionHandler()
It's hard to know what code is useful to share but if you need any more info I'm happy to provide it.
The answer seemed pretty straightforward in the end, sorry for the big question!
It was because the metadataObjectTypes was empty when the DataCaptureViewController was reloaded. So I created a viewDidAppear method and set the metadataObjectTypes to face in there.
override func viewDidLoad() {
super.viewDidLoad()
sessionHandler.setupCamera()
audioRecorder.setUpAudioSession()
createObservers()
let layer = sessionHandler.layer
layer.frame = previewView.bounds
previewView.layer.addSublayer(layer)
view.layoutIfNeeded()
jsonSentence.text = "Press start button to get phrase"
startButton.setTitle("Start", for: .normal)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
sessionHandler.metaOutput.metadataObjectTypes = [AVMetadataObject.ObjectType.face]
}
The app seems to be working now. If I've done this incorrectly though feel free to correct!
I have created a HomeScene.sks and a HomeScene.swift. In the GameViewController I've changed the default "GameScene" to "HomeScene" like this"
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.view as! SKView? {
// Load the SKScene from 'HomeScene.sks'
if let scene = SKScene(fileNamed: "HomeScene") {
// Set the scale mode to scale to fit the window
scene.scaleMode = .aspectFill
// Present the scene
view.presentScene(scene)
}
view.ignoresSiblingOrder = true
view.showsFPS = true
view.showsNodeCount = true
}
}
When I run it in the Simulator it shows the LaunchScreen but than it stops. In my xcode output screen I see:
2017-05-22 21:02:07.910 DiceWar[88707:2060079] -[DiceWar.HomeScene setNormalTexture:]: unrecognized selector sent to instance 0x7fdba6008af0
2017-05-22 21:02:07.915 DiceWar[88707:2060079] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DiceWar.HomeScene setNormalTexture:]: unrecognized selector sent to instance 0x7fdba6008af0'
I Googled around but can't find anything useful. What are these lines telling me? Did I use a bad texture? I also tried to message out all the code in HomeScene.swift but the error still occurs.
I'm not sure if it's because English isn't my native language or if it's my logic but I really don't understand what xcode is trying to tell me.
Edit
I think I found it. Because there was something with a texture. I deleted a Color Sprite from the HomeScene.sks and now it does start. When I replaced the Color Sprite there wasn't a problem until I used this line:
settingsButton = self.childNode(withName: "settingsButton") as! SKSpriteNode
The strange thing is, I used the exact some line for another image (instead of settingsButton I used playButton) The playButton line doesn't seem to be a problem.
The error message is saying that your application logic is trying to call setNormalTexture(_:) on your class DiceWar.HomeScene, but that class does not know how to handle that method call.
From the documentation:
This action can only be executed by an SKSpriteNode object.
I'm receiving a run-time error on the following statement inside of my ViewController class. This seems so straightforward, but tons of searching and videos later, I can't figure out what I did wrong.
class ViewController: UIViewController {
// Main image view controller
#IBOutlet var drawing_ImageView: UIImageView!
// store a point coordinate value based on screen touch
var start = CGPoint(x: 0, y:0)
}
The var start = CGPoint(x: 0, y:0) line throws the error. I also tried:
var start: CGPoint
but that also throws an error. What am I missing? No build or compile errors are thrown.
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
My app crashes and throws this error
[UITouchesEvent rightView]: unrecognized selector sent to instance 0x13d5092e0
2016-08-04 17:07:15.569 [3809:1375151]
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITouchesEvent rightView]: unrecognized selector sent to instance 0x13d5092e0'
*** First throw call stack:
(0x180d72db0 0x1803d7f80 0x180d79c4c 0x180d76bec 0x180c74c5c 0x1000e681c 0x1000e6a60 0x185f08be8 0x185f08b64 0x185ef0870 0x185f11360 0x185f07ed8 0x185f00c20 0x185ed104c 0x185ecf628 0x180d2909c 0x180d28b30 0x180d26830 0x180c50c50 0x182538088 0x185f3a088 0x1000f5c88 0x1807ee8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
I'm trying to make a custom class for hide and show password so that I can use it in any UITextField in any UIViewController.
class HideShowIcon:NSObject {
var showPasswordImage = UIImage(named: "ic_show_password") as UIImage?
var hidePasswordImage = UIImage(named: "ic_hide_password") as UIImage?
func hideShowPasswordButton(hideText:UITextField) {
var hideShowSize: CGSize = "12345".sizeWithAttributes([NSFontAttributeName:UIFont.systemFontOfSize(14.0)])
var hideShow: UIButton = UIButton(type: UIButtonType.System)
hideShow.frame = CGRect(x: 0, y: 0, width: hideShowSize.width, height: hideText.frame.size.height)
hideShow.setImage(hidePasswordImage, forState: UIControlState.Normal)
hideText.rightView = hideShow
hideText.rightViewMode = UITextFieldViewMode.Always
hideShow.addTarget(self, action: #selector(HideShowIcon.hideShowPasswordTextField(_:hideText:)), forControlEvents: UIControlEvents.AllTouchEvents)
}
func hideShowPasswordTextField(sender: AnyObject,hideText:UITextField) {
var hideShow: UIButton = (hideText.rightView as? UIButton)!
if !hideText.secureTextEntry {
hideText.secureTextEntry = true
hideShow.setImage(hidePasswordImage, forState: UIControlState.Normal)
} else {
hideText.secureTextEntry = false
hideShow.setImage(showPasswordImage, forState: UIControlState.Normal)
}
hideText.becomeFirstResponder()
}
}
You can not use selector with many parameters hideShowPasswordTextField(_:hideText:) for UIButton target. You can only use selector with one (or zero) parameter, in which UIButton will put itself: hideShowPasswordTextField(_:)
func hideShowPasswordTextField(sender: UIButton) {
//...
}
To use hideText in this function, you may declare it as property of your class:
var hideText: UITextField!
and assign value to it in class initialization step