In my widget, I place a header view.
var header: some View {
ZStack {
Link(destination: url) {
Rectangle().fill(Color("WidgetBackground")).frame(height: 36)
Text("Header")
}
}
}
This is a simple text on a colored background.
The url is the urlscheme for my app.
When I tap on the label or on header view, it opens my app on medium and large size widgets.
But on the small size widgets, it didnt open the app, but it flickers and reload the widget.
I also see the flicker happen in medium and large size widgets when I tap on empty spaces other than elements.
I have no clue , why this flicker happens.
Based on documentation, interacting on widget should open the app, without any extra effort.
Am I missing something ?
I don’t know why the app doesn’t open (an iOS bug, I guess), but your deeplink won’t work because Link isn’t available in the “small” widget size. You need to set the .widgetURL() modifier on your view instead.
Related
Is there a good way to hide the up down arrows in the picker default style. I am using ios 16. It seems that the older version does not have such arrows.
Also, is there a setting to set the picker's background to the same style as the datepicker in the image without manually setting the background and radious?
I have been struggling on this small feature and tried googling for a few hours but no luck. Any idea will be appreciated
The suggested Menu solution works well if you only have a few options. The problem I've experienced with the Menu solution is that if there are very many options the Menu doesn't automatically scroll to the currently selected option the way the Picker does.
The solution I've used is to use ZStack to place an opaque picker on top of a custom view (my "label"). Setting the opacity modifier on the Picker to 0.025 makes it invisible on your device but it will still trigger when you tap it.
This way you get all the native functionality of the Picker (including scrolling to the selected option) and you can make the label look any way you want without having to create your own custom picker.
Here's the code:
ZStack {
// Custom picker label
Text("\(value)")
.font(.title)
.foregroundColor(.blue)
.styleDataEntry(colorScheme: colorScheme) // a custom formatter View extension
// Invisible picker
Picker("", selection: $value) {
ForEach(0 ..< 200) { option in
Text("\(option)").tag(option)
}
}
.pickerStyle(.menu)
.opacity(0.025)
}
In the below screenshots (taken from the Apple Developer app), we can see that the Account button sticks to the bottom of the sidebar.
When the window is tall enough (left), the list doesn’t scroll, Account button’s background color has no difference. When the window is not tall enough (right), causing the list to scroll, Account button changes its background color to reveal the relationship.
The list's scroll position can not be probed. How can I declare the Account button in SwiftUI?
That app is a UIKit catalyst app and the sidebar uses scrollViewDidScroll which uses the contentSize to set a bottomButtonState which is passed into a child UIHostingController (so the account button can be SwiftUI) which I would assume switches between a clear or solid background.
We cant get the scroll info in SwiftUI however a possible workaround would be to add dummy 1 pixel high cell to the bottom of the list and using its onAppear to set a binding that is used in a bottom view to enable/disable a background colour and should achieve the same effect.
After adding a combined gesture to a view, a TextField inside the view would no longer respond when I would tap into it to change the text. I discovered this after adding a custom combined gesture - where I used a long press to start things before dragging. (Note: things still worked if just a drag gesture was added. Not sure what is particularly different between these two cases.)
The combined gesture:
let combined = longPressGesture.simultaneously(with: dragGesture)
The gesture was added to the view with:
.gesture(combined)
I got things to work by adding an onTapGesture{} to the TextField. Didn’t have to put anything into the action. Seems like a side effect whose behavior could change in the future. Appreciate any comments on if this makes sense or other ways to handle.
TextField(“Enter Text”, text: $myText)
.textFieldStyle(RoundedBorderTextFieldStyle())
.onTapGesture {}
In case one would have this issue with a drag gesture, you can set the minimumDistance. This would still register the tap on the textfield to edit it.
DragGesture(minimumDistance: 30, coordinateSpace: .global)
Adding a drag gesture in SwiftUI to a View inside a ScrollView blocks the scrolling
I am developing a touchscreen compatible app that has some widgets that contain QScrollAreas. I am using
QScroller::grabGesture(ui->scrollArea->viewport(), QScroller::LeftMouseButtonGesture);
to allow the user to easily scroll these widgets by swiping.
However, some of the scroll areas contain subclassed QGraphicsViews. I am adding QGraphicsItems to these and would like the user to be able to select items using rubberbanding. I have set the drag mode using
setDragMode(QGraphicsView::RubberBandDrag).
This works as desired if I don't also use grabGesture on the scroll area containing the view.
However, grabbing the gesture for the swipe scrolling interferes with the rubberbanding action of the graphics view.
How can I scroll widgets containing these views while also keeping the rubberbanding functionality in tact? I essentially want the widget to scroll unless the user is swiping inside of a QGraphicsView.
I've designed a toolbox control. It's inside a CDockablePane object. Since the tools inside it may need to be scrolled, I've created a CScrollView as a child of the pane and have inserted the tools inside it as children. Based on the pane size, scrollbars of the CScrollView object appear properly, but clicking on them doesn't scroll the view. It seems that they're disabled. When I use SS_NOTIFY style when creating the CScrollView, the CScrollView object receives mouse clicks, but when i don't use the style, it doesn't. But it seems that the scroll bars inside the view control don't receive clicks. When mouse hover over them, no visual effect in scroll bars appears. It seems that the scroll bars are disabled, while I've not created nor manipulate them.
What's wrong?
mouse wheel works. click on scrollbars is received by the scroll view, not by the scrollbars. inside handler, i wrote this code:
CScrollBar *pScroll = GetScrollBarCtrl(SB_VERT);
if (pScroll->GetSafeHwnd())
{
...
if is not true. this means that the scroll view has not a scroll bar, but if so, how is it shown?!
any idea?
...
since i didn't get answer, i'm going to clarify my question with a sample code:
https://dl.dropboxusercontent.com/u/4829119/930501%20-%20t3.zip
in this sample, how can i scroll my view as i do with other views like class view and file view?
the sample code screenshot:
https://www.dropbox.com/s/7pu5chpyj9hqeal/Screenshot%202014-07-23%2003.40.26.png
Did you initialize by calling SetScrollSizes? The scroll bars are enabled only when the sizeTotal is larger than the view window size.