Is there a way for me to click a button in one playground scene and then transitions to another scene? Preferably using SwiftUI
Yes, the markup formatting of Swift Playgrounds does support that. The syntax for it is
//: [Next Topic](#next)
Then you need to enable rendered markup for your playground, which you can do using Editor > Show Rendered Markup.
This is an Xcode and Swift playgrounds feature, it has nothing to do with SwiftUI or Swift itself.
For more information, see the Markup Formatting Reference Apple documentation.
Related
I found a lot of tutorials for SwiftUI where the modifier .resizable() is used on an Image.
It doesn't seem to be available anymore on Xcode 13.3.1 with Swift 5.
SwiftUI is imported. If you type the whole modifier myself is says
Local module defines have a preference over system. Taking into account context menu proposals it is your case.
The fix is to use module explicitly, like
SwiftUI.Image("myImage").resizable()
It definitely is...
Have you definitely imported SwiftUI in that file?
If you type the whole thing out does it build or does it cause an error?
From the auto completion drop down it looks like Xcode thinks you’re referring to an imageURL perhaps there is a change that Xcode hasn’t caught up with yet.
It looks like the Image you are getting is from some other module (not SwiftUI).
If you are 100% sure you don't have another import -- then I recommend exiting Xcode and deleting derived data.
rm -rf ~/Library/Developer/Xcode/DerivedData/
You are using a different Image, it's not from SwiftUI. See the color of Image is lite green(ies). You might be using an Image extension or something. Make sure while typing Image..., you select Image from SwiftUI.
We have an embedded HTML form type editor in a macOS app that needs to be filled by the user. We are using WKWebView with Swift and it's all working fine but we are not able to get the spell check working in WKWebView. I mean it does work and corrects some words but doesn't show red dotted underline on misspelled words like WebView.
WebView shows dotted redline where WKWebView does not. Found that WebView has property as isContinuousSpellCheckingEnabled but no such property is available in WKWebView.
My simple requirement to highlight misspelled words, please help if there's anything available.
I did not found it yet: so far no such property is available in WKWebView.
From apple
Description Daniel Bates 2018-08-21 11:23:20 PDT
We should render misspelled words with the spelling correction dots in
iOS WebKit (i.e. when using WKWebView). Currently we only support this
in iOS WebKit Legacy (i.e. when using UIWebView).
I am new to swift playgrounds and ran into some problems while making a swift playground in Xcode.
This is my main Playground page
import UIKit
import PlaygroundSupport
import SpriteKit
let secondScene = Index()
let master = FirstScene()
let root = UINavigationController(rootViewController: master)
PlaygroundPage.current.liveView = root
But when I tried adding Next Topic in both the source class in Swift and the playground page itself the link does not appear.
NOTE: I am using Swift Playgrounds in Xcode not a Playgroundbook on an iPad.
Also, inside sources folder of my main page I declared all classes as public, is that the right way to use the helper swift files in source?
I tried creating a new playground and added pages which have default links but still no output.
Looking at your screenshot, you've got the code right. The syntax to link to the next page is [Next Page!](#next). All you need to do now is:
- In the Xcode menu bar, click Editor
- Click 'Show Rendered Markup'
That's it. You can place markup wherever you like. Remember to replace spaces with %20 when linking to a playground page, e.g. [My Page #2](My%20Other%20Page)
You would benefit from reading Apple's Markup Formatting Reference.
To create a link to another page you will do the same thing that I did above to create a link to that reference in Markdown:
[Next Topic](Pretend%20Topic%20Name)
You can actually do something like this as well:
[Next Topic](#next)
as you know the Mail app in iOS 5 have a rich text editor is there any possible way to use this feature for a regular UITextView ?
I know of two fundamental approaches to creating a rich text editor in iOS 5:
Use Core Text and a custom view. I don't have any experience with this approach.
Use a UIWebView (instead of a UITextView) and the contentEditable HTML attribute. The basic idea is to load a custom HTML document from your app resources directory. The bare minimum that it needs is this:
<div contentEditable>TEXT_PLACEHOLDER</div>
To initialize the rich text editor view:
1. Load the contents of this file into an NSMutableString and replace the TEXT_PLACEHOLDER string with the text you want to edit.
2. Send the loadHTMLString:baseURL: message to the UIWebView with that HTML string.
Now you have a UIWebView displaying your text inside a div with contentEditable. At this point, you should be able to run your app tap on the text, and be presented with a cursor and be able to add/remove text. The next step is to add rich text formatting functionality. This is done with a set of simple javascript function calls. See the Mozilla documentation on contentEditable for a great reference. You will also want to add a Javascript function to your HTML template file like this:
function getHtmlContent() { return document.getElementById('myDiv').innerHTML; }
So you can easily retrieve the edited text as HTML using [myWebView stringByEvaluatingJavaScriptFromString:#"getHtmlContent()"]. You can also add custom context menu items like you show in the screen shot in your question.
If you have access to the Apple iOS dev center, the WWDC session Rich Text Editing in Safari on iOS talks all about this approach.
A variation of this approach is to use a third-party rich text editor like TinyMCE. I've heard of some success with integrating this into a UIWebView in iOS 5. Again this relies on the contentEditable attribute.
Here is my implementation. Still haven't added UIMenuController functionality, but it's planned to be added soon.
https://github.com/aryaxt/iOS-Rich-Text-Editor
The iOS 5 rich text edit control is also present in the notes app in iOS 4 (make a rich text note on the computer and sync it to see).
This is a custom Apple-made control which they use in their own apps, but it is not published in any official developer API. It's probably in the SDK somewhere, but because it is undocumented, even if you find it and use it, Apple will reject your app.
Basically, if you want a rich text control you will have to make your own.
Edit: Try using this: https://github.com/omnigroup/OmniGroup/tree/master/Frameworks/OmniUI/iPad/Examples/TextEditor/. I haven't used it, so I don't know how well it will work. (Link from this question)
look at https://github.com/gfthr/FastTextView which is more good open source editor than Omni editor
I am having a string message i need first word of that as bold font and rest normal.
Making different label can be create problems,(need to find the size of first the make other and then make other,text is in 4 line).
How can i use NSAttributedString here. I could found How do you use NSAttributedString?
but using this shows undeclared NSForegrou... (present in app kit framework).But could not found app kit framework on sdk 4.2
Need help for making such kind of string(bold + normal text).
Go through the below blog tutorial with code, they have different font with NSAttributedString.
http://www.cocoanetics.com/2011/01/rich-text-editing-on-ios/
https://github.com/Cocoanetics/NSAttributedString-Additions-for-HTML
https://github.com/omnigroup/OmniGroup/tree/master/Frameworks/OmniUI/iPad/Examples/TextEditor
May I point you to the CoreText Framework and Befriending Core Text on cocoanetics.com. This will show you how to format text.