So the QuickLookPreview displays correctly as usual, but when you try and use the Apple built-in sharesheet it is sliding up a see-through grey view that is displaying nothing else on it. Has anyone had experience with this?
Thought it might be something obscure like an alpha view in the background...
Appreciate any good suggestions.
So in our case this was being caused by an Activity extension that was not even being used anymore. Super weird bug that took quite a lot of digging to find, but posting it here just in case anyone else has similar weirdness one day and can have a better time of it.
extension UIActivityViewController {
override open func viewDidLoad() {
super.viewDidLoad()
//self.unusedfunction()
}
func unusedfunction() {
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UIActivityViewController.self]).setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.Theme.Black], for: .normal)
}
}
So the issue was being caused by the super.viewDidLoad() and we just had to delete/comment out that extension for the share feature to start displaying correctly again.
Related
A quick question. I use to see the inferred type by option click the property or object on the left of a statement. After upgrade to Xcode 13, for instance, when I option click on below text property, there is no quick help popping up. Do u guys meet this same issue? Just Google it, no clue found.
let text = "Have a nice day"
Quick help is only shown when I option-click on an iOS built-in property, function, etc. It doesn't appear for custom defined things.
For code below, when I optional click on viewDidLoad or addSubview , I could get quick help menu popped up. But without luck for tableView, which is a user defined stuff.
private lazy var tableView: UITableView = {
let table = UITableView()
table.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
return table
}()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(tableView)
tableView.frame = view.bounds
}
Well, restart your Mac will solve this problem. It seems I had not restarted my Mac since the day I upgrade to Xcode 13.
The issue link in Apple forum: link
For me restarting the Mac, cleaning build folder and derived data + quitting Xcode didn't help.
Seems like it works only on small projects, but not on the one for the company I work for. It's pretty random and extremely annoying, no idea what could fix it honestly
A "tried and true" pattern I've used in my iOS Swift app is that I have several areas with UIButtons. When the button is pressed, it fires off some net code that connects to my API. While this is happening, I have the button text say "please wait, loading" and I disable the button. When the queued action finishes in my callback I have the button text enable and change back to the original state. It works great.
I recently added something not using NSURL/NSDATA (it's just a file writer). I copied all the same GCD queue code and oddly enough it doesn't update the button text.
Here is my code. When you tap the button, the text becomes invisible until the callback finishes, and then it just restores back. Oddly enough if I change my simulator to iPad Pro it actually works (??) and says "please wait, downloading". If I switch to iPhone 6s it doesn't work.
#IBAction func btnGenerateCSV(sender: UIButton) {
//Grab the original text of the button to restore later after done
let originalButtonText = sender.titleForState(UIControlState.Normal)
//Localized is an extension function I wrote.
//As you can see I got crazy here adding all the UI States as a last ditch attempt to see if that was the reason.
sender.setTitle(Localized("Downloading"), forState: UIControlState.Normal)
sender.setTitle(Localized("Downloading"), forState: UIControlState.Disabled)
sender.setTitle(Localized("Downloading"), forState: UIControlState.Highlighted)
//I've tried moving this before the setTitle. No avail.
sender.enabled = false
//I've tried the other queues as well, and even just tried dispatch_async(dispatch_get_main_queue()) but no luck
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0)) { [unowned self] in
CsvReportWriter.GenerateReport()
{
r in
dispatch_async(dispatch_get_main_queue()) {
FileManager.WriteToFile(r, filename: self.filename)
if FileManager.FileExists(self.filename) {
self.docController = UIDocumentInteractionController(URL: FileManager.GetURLOfFile(self.filename))
self.docController.presentOptionsMenuFromRect(sender.frame, inView:self.view, animated:true)
}
//Restore button state and text b/c we're done
sender.enabled = true
sender.setTitle(originalButtonText, forState: UIControlState.Normal)
}
}
}
}
Any ideas? If I swap out the CsvReportWriter.GenerateReport() code with some other async code that does a call out to my API, it works.
Thanks so much!
So I wanted to post an answer that I thought was interesting - I had a different account logged in to my iPad Pro simulator.. and noticed that the label correctly appeared. In iPhone 6 it did not. I was logged into a different account.
So what was the difference? There were about 1,000,000 test rows to generate in the iPad pro, and 3 in the iPhone, so everything finished so fast there was no UI to even update.
I introduced a delay just as a test, and noticed that in fact it works / exports so that's actually what it was.
So it turns out things were running so fast there wasn't even time to update to 'please wait' lol
Sorry to bother anyone but feel free to use the above code as it should be effective to do what you need :)
I'm a beginner at developing for iOS, and after doing some research on the web, I still couldn't find a way that I can set a button to copy the entire text from a textview. I've seen some tutorials but most of them are old, and some of them are very confusing. Any help would be appreciated, thanks.
try this,
#IBAction func copyButton(sender: AnyObject) {
UIPasteboard.general.string = textToCopy.text
}
I have a Today Widget for my app, however I have been told about an issue with it.
Basically, what seems to be happening (I can't test this for myself) is that the widget will sometimes just display 'unable to load' and other times it will just display with a height of 0.
I can't really see why this is happening. I've tested it out on my device and the simulator for weeks now and have never ran into this issue.
I was wondering if it could possibly be down to the refresh code:
func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)!) {
// Perform any setup necessary in order to update the view.
var defaults = NSUserDefaults(suiteName: "group.AffordIt")
var newCheck = defaults.boolForKey("new")
if newCheck == true {
completionHandler(NCUpdateResult.NewData)
} else {
completionHandler(NCUpdateResult.NoData)
}
}
'newCheck' is true whenever something changes within my app that needs to be displayed in the widget.
Does anyone know what the possible causes of these issues are?
"unable to load" message appears if your extension crashes often. You can try to re-enable it by removing and adding the extension again.
Are you using your own view controller and xib instead of using storyboard? If yes, it is probably that you didn't set the preferredContentSize in your view controller.
try to put the following code in the init function of ur view controller:
self.preferredContentSize = CGSizeMake(320, 100);
I have just began the extension programming today so I am not sure is it really helpful for u or not. Here is the result in my own widget:
Press Edit button in today extensions
Remove your extension
Add your extension again.
I've been developing a custom keyboard for iOS 8, but stumbled upon a problem trying to send images using the keyboard. I did some research and it seems like there isn't a simple way to do this with UITextDocumentProxy because only NSStrings are allowed.
Am I either overlooking any simple ways to use a custom keyboard to send images and/or is there any way to work around this issue?
Thanks in advance
Apparently, you are not the only person to try a keyboard like this. If you look at the animated GIF on the site, the keyboard uses copy/paste to add the image to the messages.
The UIKeyInput Protocol, which is inherited by UITextDocumentProxy, has the following function:
func insertText(_ text: String) //Swift
- (void)insertText:(NSString *)text //ObjC
These only take a String or an NSString, as you already know. Because there are no other methods to insert content, it can be assumed that, currently, there is no other way.
Right now, I would suggest that you adopt a similar usage. When the user taps on the image, add it to the UIPasteboard. Maybe present a little banner on top of the keyboard saying, "You can now paste" or something, but that would be up to you to decide.