I update my Xcode to the latest version today. After that, I can't access the developer documentation from the Xcode anymore.
The error report says:
Application Specific Information:
Sending windowMenu_showDocumentation: to IDEDocCommandHandler from <NSMenuItem: 0x7f99fa73ee00 Developer Documentation>
ProductBuildVersion: 12A7209
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEPlugins/IDEPlugins-17192/IDEDocViewer/DocumentationNavigator.swift:142
How can i solve the problem? Thanks in advance.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I want to test the code below in live preview, but it seems not to work. In simulator, the button can change the text well, but not in live preview. How to fix it? Thanks in advance.
import SwiftUI
struct PreviewOnchangeTest: View {
@Binding var toggle: Bool
@State var text = "nice"
var body: some View {
VStack{
Text("\(text)")
.onChange(of: toggle, perform: { value in
text = toggle.description
})
Button(action: {toggle.toggle()}, label: {
Text("change")
	})
}
}
}
struct PreviewOnchangeTest_Previews: PreviewProvider {
@State static var toggle = true
static var previews: some View {
PreviewOnchangeTest(toggle: $toggle)
}
}
According to the documentation of ".offset", The original dimensions of the view aren’t changed by offsetting the contents; in the example below the green border drawn by this view surrounds the original position of the text:
Text("Hello, World!")
.border(Color.black)
.offset(x: 10.0, y: 50)
.border(Color.green)
IMO, the modifer (ie,.border(Color.green))followed ".offset" should only affect the original view, but not the new view.
When add a ".frame" right after the ".offset", I thought it also only affect the original view. However, the original and the new view are both affected.
Text("Hello, World!")
.border(Color.black)
.offset(x: 10.0, y: 50)
		.frame(width:50)
.border(Color.green)
Further more, if I keep adding another ".frame" right after the first one, only the original view is affected again.
Text("Hello, World!")
.border(Color.black)
.offset(x: 10.0, y: 50)
.frame(width:50)
.frame(width:100)
.border(Color.green)
What happened under the hood? Thanks in advanced.
I want to demonstrate a large size image(5184*3456) in a modal sheet with swiftui.
When I popup the sheet, memory usage increases from 20mb up to 100mb. However, when I dismiss the sheet, memory usage just decreases from 100mb to 92mb, wear and tear. I popup the sheet again, memory usage increases from 92mb back to 100mb.
Back and forth, memory usage always changes between 92mb and 100mb, instead of between 20mb and 100mb that I expect to. Why doesn't memory usage decrease to 20mb when the sheet dismiss? Why doesn't image been purged from memory when the sheet dismisses? I just want memory usage stays in a low level. How could I do? Thanks in advance.
struct IntroductionView: View {
@Environment(\EnvironmentValues.presentationMode) var presentation
var body: some View {
GeometryReader{geo in
VStack(alignment:.leading){
Image("image")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(maxHeight:geo.size.height/4)
.clipped()
Spacer()
Button(action: {
presentation.wrappedValue.dismiss()
}, label: {
Text("Close")
}
}
}
}
}
I drag a image.jpg into the assets.xcassets. And I want to read the jpg data in my code by
"var imageData = NSDataAsset(name: "image")?.data"
However, I get an error: "CoreUI: attempting to lookup a named data 'image' with a type that is not a data type in the AssetCatalog". And "imageData" is always nil.
Do I make a mistake or miss sth? Thanks in advance.
I want to set "ringer and alerts" sound in code.
MPVolumeView() seems like to control the system volume only. I have some sound effect(by invoking "AudioServicesPlaySystemSound(SystemSoundID:)") affected by "ringer and alerts" in my app. Even when the system volume is max, my app sound effect is still mute if "ringer and alerts" sound is mute. I have to tune "ringer and alerts" by "setting-sounds-ringer and alerts" manually.
Is there any programable way to set it? Any help will be greatly appreciated.
In swift language guide-"Opaque Types"-"Differences Between Opaque Types and Protocol Types", it said:
"Another problem with this approach is that the shape transformations don’t nest. The result of flipping a triangle is a value of type Shape, and the protoFlip(:) function takes an argument of some type that conforms to the Shape protocol. However, a value of a protocol type doesn’t conform to that protocol; the value returned by protoFlip(:) doesn’t conform to Shape. This means code like protoFlip(protoFlip(smallTriange)) that applies multiple transformations is invalid because the flipped shape isn’t a valid argument to protoFlip(:)"
I can't understand why it said"a value of a protocol type doesn’t conform to that protocol; the value returned by protoFlip(:) doesn’t conform to Shape". The return value must conform to Shape. It's a fundamental requirement by function signature, isn't it?
I know I can use .redacted(reason: .placeholder) to make displayed data appear as generic placeholders. But how can I declare a custom RedactionReasons instance and use it? The examples of initializer in documentation seem not to be helpful. Thanks in advance.
In the simulator, everything is ok. However, in live preview mode of canvas, no keyboard pops up when I tap in the textfield. Did I miss anything? Or need more codes in preview?Thanks in advance.
I want to perform some code when the form is tapped. However the button in the form is affected by the onTapGesture either. I want the button tapped to execute the action block, not the onTapGesture block. How should I do? Thanks in advance.
struct TextFieldPopupView: View {
@State private var text = ""
@State private var isON = false
var body: some View {
Form{
Text("Hello")
TextField("Hello", text: $text)
.textFieldStyle(RoundedBorderTextFieldStyle())
Button(action: {
print("Button")
}, label: {Text("Button")})
Toggle(isOn: $isON, label: {
Text("Toggle")
})
}
.onTapGesture {
print("Form")
}
}
}
I wrote some code using LazyVGrid.
struct LazyVStackTestView: View {
let columnGridItem = Array(repeating: GridItem(), count: 3)
var body: some View {
GeometryReader{geo in
HStack{
Rectangle().frame(maxWidth: 300,maxHeight: 100)
LazyVGrid(columns: columnGridItem){
ForEach(1..<13) { btn in
Image(systemName: "plusminus.circle")
.resizable()
.scaledToFit()
.clipShape(Circle())
}
}
.padding()
.frame(maxWidth: geo.size.height*0.6, maxHeight: geo.size.height)
}.border(Color.black)
.padding()
}.border(Color.blue)
}
}
When run it on simulator(iPhone 11) in horizontal orientation, I get a 4rows3columns button pad that is what I want. But when I turn the simulator to vertical orientation and back to horizontal orientation immediately, the button pad becomes 3rows3columns! What had happened?
Any help will be appreciated.
I have an app released in the iOS store which is set to be price tier 1. I want to set it to be free for just next week. After that, the price should be back to price tier1 again. If I
tune it in App Store connect. Will it make my app to be in review again, or just take effect immediately? Thanks in advance.
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
App Review
App Store
App Store Connect
I downloaded sf symbol3 today. My Xcode is 12.5. When I write a simple code like:
Image(systemName: "gearshape")
everything is ok. However when the code turns to :
Image(systemName: "gearshape.circle")
nothing will be displayed.
Do I miss anything? Thanks in advance.
struct PickerStyleView: View {
@State private var num = 0
var body: some View {
Form{
Text("Number")
Picker(String(num), selection: $num, content: {
Text("5").tag(5)
Text("10").tag(10)
Text("15").tag(15)
Text("20").tag(20)
})
.pickerStyle(InlinePickerStyle())
}
}
}
Using InlinePickerStyle() and WheelPickerStyle() seems to be no difference.
What does "InlinePickerStyle()" refer to? And which case is "InlinePickerStyle()" suitable for in practice? Any help will be appreciated.
struct ProblemSegmentTest: View {
@State private var select = 0
var body: some View {
VStack {
Picker("Test", selection: $select) {
Text("A").tag(0)
Text("B").tag(1)
Text("C").tag(2)
}
.pickerStyle(SegmentedPickerStyle())
}
.onTapGesture {
print("test")
}
}
}
I want to do sth when the picker is taped. However, when I apply ".onTapGesture" to the vstack, the picker's options can't be selected any more. Any help will be appreciated.