Comments (13)
That's odd, sizeThatFits
is of course a UIKit function. Are you doing any background/multi threading? Does it occur 100% of the time?
Maybe try setting a breakpoint on that line, and then making sure sublabel
isn't nil before the crash. Not sure why it would be nil, but that could explain the EXC_BAD_ACCESS. You might need to follow some of the general guidelines to debuggin an EXC_BAD_ACCESS.
from marqueelabel-swift.
It only occurs when I use 2-3 smaller letters.
Don't think i am using background / multithreading. But I am a noob. So probably not ;-)
from marqueelabel-swift.
Hmm, I might need an example project that has the issue. It's sounds like you're using an attributed string? It might have something to do with that.
You could try making a regular UILabel that's the same size onscreen, assigning your string (and font, etc), and then calling sizeThatFits
on it just like MarqueeLabel does. If it crashes on that, it's unfortunately an iOS issue!
from marqueelabel-swift.
Will give you access later
I am also having some lagging issues. The label isnt scrolling as smooth as excepted
Am 28.01.2016 um 15:53 schrieb Charles Powell [email protected]:
Hmm, I might need an example project that has the issue. It's sounds like you're using an attributed string? It might have something to do with that.
You could try making a regular UILabel that's the same size onscreen, assigning your string (and font, etc), and then calling sizeThatFits on it just like MarqueeLabel does. If it crashes on that, it's unfortunately an iOS issue!
—
Reply to this email directly or view it on GitHub.
from marqueelabel-swift.
Did you have any luck with this?
from marqueelabel-swift.
no. could you have a look please?
//
// ViewController.swift
// word_swift
//
// Created by Jonathan Arnold on 22.11.15.
// Copyright © 2015 Jonathan Arnold. All rights reserved.
//
import C4
import UIKit
import CoreData
import Foundation
import QuartzCore
import AVFoundation
class ViewController: C4CanvasController, UITextFieldDelegate {
@IBOutlet weak var textField: UITextField!
var bigBannerStatic = UILabel()
var bigBannerScrolling = MarqueeLabel()
let screenSize: CGRect = UIScreen.mainScreen().bounds
var screenWidth: CGFloat!
var screenHeight: CGFloat!
var string = ""
override func setup() {
canvas.backgroundColor = black
}
override func viewDidLoad() {
super.viewDidLoad()
screenWidth = screenSize.width
screenHeight = screenSize.height
NSNotificationCenter.defaultCenter().addObserver(self, selector: "orientationChanged", name:
UIDeviceOrientationDidChangeNotification, object: nil)
var color: UIColor = UIColor.grayColor()
textField.attributedPlaceholder = NSAttributedString(string: "", attributes: [NSForegroundColorAttributeName: color])
textField.delegate = self
bigBannerScrolling.text = ""
bigBannerScrolling.frame = CGRectMake(0, 0, screenHeight, screenWidth)
bigBannerScrolling.textAlignment = .Center
bigBannerScrolling.font = UIFont.monospacedDigitSystemFontOfSize(screenWidth - 50, weight: UIFontWeightRegular)
bigBannerScrolling.textColor = UIColor.whiteColor()
bigBannerScrolling.type = .Continuous
bigBannerScrolling.scrollDuration = 15.0
bigBannerScrolling.fadeLength = 30.0
bigBannerScrolling.animationDelay = 0.0
bigBannerScrolling.leadingBuffer = 200.0
bigBannerScrolling.textAlignment = .Left
bigBannerScrolling.trailingBuffer = 200.0
bigBannerStatic.text = ""
bigBannerStatic.frame = CGRectMake(0, 0, screenHeight, screenWidth)
bigBannerStatic.textAlignment = .Center
bigBannerStatic.font = UIFont.monospacedDigitSystemFontOfSize(screenWidth - 50, weight: UIFontWeightRegular)
bigBannerStatic.textColor = UIColor.whiteColor()
bigBannerStatic.adjustsFontSizeToFitWidth = true
bigBannerStatic.numberOfLines = 0
bigBannerScrolling.alpha = 0.0
bigBannerStatic.alpha = 0.0
view.addSubview(bigBannerScrolling)
view.addSubview(bigBannerStatic)
bigBannerScrolling.pauseLabel()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(animated: Bool) {
textField.becomeFirstResponder()
}
func orientationChanged()
{
if(UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation))
{
bigBannerScrolling.pauseLabel()
// print("landscape")
textField.resignFirstResponder()
bigBannerStatic.text = textField.text
bigBannerScrolling.text = textField.text
string = bigBannerStatic.text!
UIView.animateWithDuration(0.25, animations: {
// self.bigBannerStatic.alpha = 1
self.bigBannerScrolling.alpha = 1
self.textField.alpha = 0
})
delay(0.6, closure: {
self.bigBannerScrolling.unpauseLabel()
})
var textcountSpeed = bigBannerScrolling.text!.characters.count / 3
bigBannerScrolling.scrollDuration = CGFloat(textcountSpeed)
// sayHello()
}
if(UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation))
{
// print("portrait")
textField.becomeFirstResponder()
UIView.animateWithDuration(0.25, animations: {
self.bigBannerStatic.alpha = 0
self.bigBannerScrolling.alpha = 0
self.textField.alpha = 1
})
bigBannerScrolling.pauseLabel()
}
}
func sayHello() {
var utterance = AVSpeechUtterance(string: string)
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
utterance.rate = 0.25
var set_language = "en-US"
var voice = AVSpeechSynthesisVoice(language: set_language)
// Check for language
if (NSUserDefaults.standardUserDefaults().objectForKey("voice_language") == nil) {
set_language = "de-DE"
voice = AVSpeechSynthesisVoice(language: set_language)
print("default")
} else {
print("yallla")
}
utterance.voice = voice
var synthesizer = AVSpeechSynthesizer()
synthesizer.speakUtterance(utterance)
}
func delay(delay:Double, closure:()->()) {
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
Int64(delay * Double(NSEC_PER_SEC))
),
dispatch_get_main_queue(), closure)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
from marqueelabel-swift.
You need to install the C4 Pod to run it
from marqueelabel-swift.
It seems to run fine for me (in the simulator and on an iPhone 6), is there a specific string that always leads to crashes?
I just threw a basic UITextField on the Storyboard and connected it up to get things to work.
from marqueelabel-swift.
Can you try it "aii"?
I also experience that the text isn't running as smoothly as expected. Do you see what i mean?
Am 09.02.2016 um 02:20 schrieb Charles Powell [email protected]:
It seems to run fine for me (in the simulator and on an iPhone 6), is there a specific string that always leads to crashes?
I just threw a basic UITextField on the Storyboard and connected it up to get things to work.
—
Reply to this email directly or view it on GitHub.
from marqueelabel-swift.
Hmm no issues with "aii" on an iPhone 6 (simulator or device) - maybe it's hardware/screen size related? What are you running it on?
I do see a slight jitter/jump once per loop, right as an animation completes and another starts, so there is an opportunity for a performance improvement there.
from marqueelabel-swift.
I think I've accidentally stumbled upon the problem. I was playing with it today and found that the crash seemed to occur with most (all?) strings when I left the simulator in landscape orientation between application launches - i.e. it would crash when the app was launched while in landscape.
It has something to do with the usage of pauseLabel
causing runaway recursion of the animation completion block, which eventually causes the crash. pauseLabel
and unpauseLabel
are intended to be used for already-in-flight animations, as opposed to "stopping" a label as you're doing.
A safer way to handle what you want to do would be to use holdScrolling
. Try changing all your usages of pauseLabel()
and unpauseLabel()
like so:
// bigBannerScrolling.pauseLabel() — becomes:
bigBannerScrolling.holdScrolling = true
// bigBannerScrolling.unpauseLabel() — becomes:
bigBannerScrolling.holdScrolling = false
I'll think about finding a way to make pauseLabel
usage a bit safer, so that it doesn't result in weird behavior like you encountered.
from marqueelabel-swift.
Thank you, that seems to solve it.
Is there a solution for the laggy animation?
Am 10.02.2016 um 00:00 schrieb Charles Powell [email protected]:
I think I've probably accidentally stumbled upon the problem. I was playing with it today and found that the crash seemed to occur with most (all?) strings when I left the simulator in landscape orientation between application launches - i.e. it would crash when the app was launched while in landscape.
It has something to do with the usage of pauseLabel causing runaway recursion of the animation completion block, which eventually causes the crash. pauseLabel and unpauseLabel are intended to be used for already-in-flight animations, as opposed to "stopping" a label as you're doing.
A safer way to handle what you want to do would be to use holdScrolling. Try changing all your usages of pauseLabel() and unpauseLabel() like so:
// bigBannerScrolling.pauseLabel() — becomes:
bigBannerScrolling.holdScrolling = true// bigBannerScrolling.unpauseLabel() — becomes:
bigBannerScrolling.holdScrolling = false
I'll think about finding a way to make pauseLabel usage a bit safer, so that it doesn't result in weird behavior like you encountered.—
Reply to this email directly or view it on GitHub #22 (comment).
from marqueelabel-swift.
Glad that fixed it! I've pushed [release 2.6.4] which might improve the end-of-loop jump somewhat, although it doesn't completely eliminate it from your sample application. Other than that, scrolling does look poor in the simulator but on-device it's very smooth for me (aside from the noted jump).
I'll open a separate issue for the end-of-loop jump, which seems to be a problem related to using a zero-length delay.
from marqueelabel-swift.
Related Issues (20)
- Thread 1: EXC_BAD_ACCESS HOT 2
- MarqueeLabel.swift Line 1264 Thread 1: EXC_BAD_ACCESS (code=2, address=0x7fff4f8daff8) HOT 1
- Seemingly random crashes in applyGradientMask:animated: HOT 22
- One MarqueeLabel is not scrolling HOT 3
- "MarqueeLabel: Failed to find t for Y input!" HOT 5
- Does not compile for Swift 1.2 HOT 2
- Text Not Visible/Offset to the left HOT 4
- NSNotification crash HOT 4
- Zero-length delay with continuous scrolling causes animation jitter HOT 1
- Still doesn't compile
- cant import to swift project "import MarqueeLabel-Swift" HOT 2
- Slow Performance... HOT 9
- Speed issue of label HOT 2
- Label is throwing an exception HOT 4
- Bug: Font resets to System/default on Continuous Scroll HOT 1
- Have a property to avoid looping HOT 1
- No scroll in CustomCell in TableView HOT 3
- Question: When will be availbale via pod install? HOT 3
- Line height is incorrect when using mutiple attributed strings in a custom table cell HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marqueelabel-swift.