uilabel

if UILabel.text = [different Chinese Strings], memory leak?

喜欢而已 提交于 2019-12-11 17:57:01
问题 I was solving my app's memory leak problem, I narrowed the scope, and found out the "leak" (instruments didn't say leak, but memory went up) came from this method: - (void)loadDataSource { self.enLabel.text = self.dataSource.en; // English words self.cnLabel.text = self.dataSource.cn; // Chinese translation } The app is a flash cards app. Swipe to switch to next card. Tap to see answer(cnLabel.hidden = NO). It has only 2 CardView, when prepareing next card, cardView.dataSource will be set,

UILabel subclass ignores foregroundColor in Attributed string when label uses a named color

半世苍凉 提交于 2019-12-11 17:43:41
问题 I just came across a very strange problem in a custom UILabel subclass and I need some help to figure out what is going on. The question appears to be pretty long, but this is mostly due to the images I have added to illustrate the problem as good as possible :-) Thank you very much for your help! The MyHTMLLabel class uses the awakeFromNib() method to parse its text property for HTML like <hightlight> tags to show the text between these tags in a a different color. This has worked without

Display superscript % using NSNumberFormatter

不问归期 提交于 2019-12-11 17:33:22
问题 I'm using an NSNumberFormatter to display a percentage: NSNumberFormatter *inclineFormat = [[[NSNumberFormatter alloc] init] autorelease]; [inclineFormat setMinimumFractionDigits:1]; [inclineFormat setNumberStyle:NSNumberFormatterPercentStyle]; It's working as expected with the exception that the design team would like to see the "%" in superscript. Is there anyway to specify that using NSNumberFormatter? I'm displaying the formatted string in a UILabel in iOS devices. 回答1: % does not exist

The TableView problem…A view with indicator..in particular row

社会主义新天地 提交于 2019-12-11 17:07:49
问题 Few hours ago I did ask this Question ..And my problem got solved.. The TableView problem...How to know the row number Now in this question I want to add this.. what I am doing I am making a project in which I am using a tableView. In that tableView After deleting the row A new view should be shown on that row with activity indicator and a label...and label shows...row deleted.. My Problem Again I am stuck with the problem that is when I press the button ..the button of the particular row

Swift: Incrementing label with delay

久未见 提交于 2019-12-11 16:54:36
问题 My app freezes when it reaches this part of the code. I am attempting to increment a number with a half of a second delay, then printing that to the screen. So the label text would turn into a 1, then a 2, then a 3, etc. I threw this code into playground and the DispatchQueue seems to infinitely go up. Thanks. var percentage = 0 func incrementLabel (amount: Int){ var count = 0 while count <= amount{ DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: { percentage += 1 count += 1 })

AVCaptureVideo not showing label

空扰寡人 提交于 2019-12-11 16:00:10
问题 I am trying to retain the objects from the console to be shown in as a label(classifierText). The warning of "UILabel.text must be used from main thread only" appears. What seems to the problem as to why the items are being shown as the label? var previewLayer: AVCaptureVideoPreviewLayer! let classifierText: UILabel = { let classifier = UILabel() classifier.translatesAutoresizingMaskIntoConstraints = false classifier.textColor = .black classifier.font = UIFont(name: "Times-New-Roman", size:

NSAttributedString with padding before and after the text and a background

孤人 提交于 2019-12-11 15:59:43
问题 I want to style a text using NSAttributedString . The text should have a background and a custom padding, so that the text has a little bit of space to the background's edge. This is what I want to achieve: This is what I don't want to achieve (background in the second line is not word / character-specific): And this is the code that I tried in a playground: let quote = "some text with a lot of other text and \nsome other text." let paragraphStyle = NSMutableParagraphStyle() paragraphStyle

Where do you declare UITapGestureRecognizer() in relation to addGestureRecognizer() in Swift?

房东的猫 提交于 2019-12-11 15:56:30
问题 Problem centerLabelGesture is being defined outside of the scope of viewDidLoad() , so at the time that .addGestureRecognizer(centerLabelGesture) is called, centerLabelGesture is not defined yet. import UIKit import SnapKit class ViewController: UIViewController { var screen: UIView! var centerLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() screen = UIView() centerLabel = UILabel() view.addSubview(screen) screen.addSubview(centerLabel) screen.backgroundColor = .white screen

Adding a space before and after the text in UILabel using the storyboard

岁酱吖の 提交于 2019-12-11 15:24:04
问题 How to add a space before and after the text in UILabel using storyboard. Here is an example of label with a background. 回答1: One approach is: Use auto layout in the storyboard. Use a UILabel subclass that overrides intrinsicContentSize to be a little wider than the default. For example: extension CGSize { func sizeByDelta(dw dw:CGFloat, dh:CGFloat) -> CGSize { return CGSizeMake(self.width + dw, self.height + dh) } } class MyWiderLabel : UILabel { override func intrinsicContentSize() ->

Get all attributes of an entity to a label in row in tableview with core data swift ios

痴心易碎 提交于 2019-12-11 14:33:20
问题 I have defined the two attribues Name and description to an entity named Forms and I want retrieve the name in first label and desc in 2nd label in a row of a tableview what I have made what I cuurently retrieve I want these all values to be printed in every cell instead of sigle cell repeated every time let context = appDel.persistentContainer.viewContext let results = try! context.fetch(request) for result in results as! [NSManagedObject] { let formNameIs = result.value(forKey: "formName")