I'm currently facing a strange problem: I'm showing images in a listview. As a nice additional thing I want to show the exif data of the images also.
Therefore I came up with the following construction using a flipable component:
Component{
id: flippableDelegate{
Flipable{
property bool flipped: false
front: Images{}
back: ExifData{}
}
}
ListView{
delegate: flippableDelegate
}
So everything works fine: I can scroll through my images and flip them by clicking on them.
The strange thing nonetheless is the following:
I flip one image (e.g. index = 3) and i flick to the next while image 3 is still flipped. When flicking back to image 3 its not flipped anymore.
I guess this is clear, as the boolean flipped is set to false all the time.
I do like that feature!
BUT it doesnt work for the first image (index 0). Why?
The delegates are unflipped when flicked out of view because they are destroyed and recreated when flicked back into view.
The first item is the currentIndex and is not destroyed when it is flicked outside the view because the currentItem must not be destroyed.
If you are not interested in using currentIndex/currentItem then you can simply set currentIndex: -1 and it should work as you desire.
As a word of warning: QtQuick 2.0 may not destroy delegates when they are flicked out of view as it has a non-zero cacheBuffer by default.
Related
How can you blur the whole view except a single table view cell?
The effect should be similar to the 3D touch blur effect. E.g. Mail app:
The effect of blur applies precisely to the whole screen but the selected cell in the case of the mail app.
If you only want the effect to apply to your table view, you could maybe put a blur visual view on tope of your each cell's content, and set its effect to nil
cell.blurView.effect = nil
appart when one cell is selected. To do that, play with the didSelectRow function and reload the data so that at the end you get the effect you want. (you can even animate the change with UIView.animate())
UIView.animate(withDuration: 0.5, animations: {
cell.blurView.effect = UIBlurEffect.init(style: .light)
}
The problem is that the solution I told you is not very power efficient, but I can think of another one:
Consider having two blur view that display no effect when no cell is selected, then you can as soon as the cell is selected, set the two blur view so that the first one takes the whole part of the screen at the TOP of your cell, and the other one covers the BOTTOM.
Ok last idea:
you could, in the didSelectRow method, add a blurView to the whole screen
UIApplication.shared.keyWindow?.addSubview(blurView)
and then add the cell on top of that and of course removing all this when the blur view is tapped for example
Hope it helps ;)
I'm currently making an OS X app with an NSScrollView. The scroll view's cells have a small "X" in them that allows me to remove them one at a time. However, whenever a cell is removed, the lower cells get pushed up to fill the space via a short animation. I'm wondering how to disable this animation so that the lower cells are instantly pushed up as soon as the cell is removed. Any help is appreciated!
Edit: The contents of the scroll view are maintained via an NSArrayController, so removing clicking the "x" sends a notification to an observing delegate which in turn calls:
-(void)alertRemoved:(NSNotification*)notification{
// Random code
...
[eventArrayController removeObject:alert];
}
maybe this is a rather simple question. I don't know. I searched the forums for an answer but couldn't find one. I have two views. From a tablecell I push to a second view which contains a scrollview (960 x 455). This scrollview is centered when loaded.
Whenever I push into this view, the left part of the scroll which shouldn't be visible right away shows up for a few seconds. The same happens when I push back. Is there a way to push into the second view and only show the center of the scrollview?
I would have thought that this is occurring because the view is being loaded and then afterwards the position is being set which can take a while when the view is first being loaded as their other things being processed before setting the position.
I am presuming you are using interface builder if so I recommend setting the UIScrollViews visible/hidden property to true in there then in the viewDidLoad method setting it's position to centre after which you can set it to be visible again.
Yesterday I failed to get an answer, but perhaps I did not understand the problem deep enough to formulate correct question.
The story is about animating ListBox height. Here are subsequent screenshots:
a) "Medium" is a TextBlock
b) "Medium" TextBlock gets replaced by a ListBox. The user selects an item. That initiates animation of the ListBox.Height. After the animation completes, the ListBox is replaced by original TextBlock.
(Disregard the differences in data. Collection of the images was a painfull process, when I had to work with rendered frames. One of the images was shot for different record.)
This sequence works with occasional flickering. I wanted to know what's going on and after a while I got this screenshot:
What you see is the first frame after Storyboard.Completed event was intercepted. As far I understand this is the final result from the Storyboard.
Notes:
I checked the visual tree at this instant and did not find anything suspiceous.
This is just one of the effects that happen. Another frequent case is a resized 1-line ListBox with blue hatching; in this case all elements above the listbox disappear. 3rd possibility is a diagonal red line over the whole screen.
Here is the code defining the Storyboard:
private Storyboard GetDropDownAnimation(double from, double to)
{
double secs = this.IsExpanded ? 0.2 : 0.4;
CubicEase ease = new CubicEase() { EasingMode = EasingMode.EaseInOut };
DoubleAnimation animation = new DoubleAnimation()
{
Duration = new Duration(TimeSpan.FromSeconds(secs)),
From = from,
To = to,
FillBehavior = FillBehavior.HoldEnd,
EasingFunction = ease
};
Debug.WriteLine("Animation Height {0} -> {1}", from, to);
Storyboard.SetTarget(animation, this);
Storyboard.SetTargetProperty(animation, new PropertyPath("Height"));
Storyboard sb = new Storyboard();
sb.Children.Add(animation);
return sb;
}
I could explain other tricks done (for a long time I was convinced that the problem is there), but it looks like the problem concerns only the animation itself.
Anybody able to explain what's going on?
Have a look at these before you continue this way it might make your life a bit easier :)
That said, have a look at the starting value of the animation (from) and see if it is correct.
If all else fails you could start with a fully transparent listbox.
I made some progress on the problem that may be worth of reporting.
At first I replaced Storyboard by own animations. I started by using CompositionTarget.Rendering callbacks. The code is fairly trivial: In the callback you need to update the ListBox height proportionally to the elapsed time. I double-checked that for each height change there is one LayoutUpdated event, in other words the screen is in sync all the time. (A pleasant surprise.)
The result: Flickering remained.
Conclusion: Storyboard is innocent.
Then I found something interesting:
Because the height manipulation was in my hands I simply rounded the value to the whole multiple of the row height. And guess what - flickering disappeared!
Note the ListBox in question is set up using ItemsSource and DisplayMemberPath that refers to a string property. ItemTemplate is not set. In other words pretty standard ListBox use.
It is not an answer, I know, yet I find it interesting.
I would like to create an infinite scrollView (like a slot machine), but without paging. When the user scrolls down, it's easy i just have to increase the contentSize and the scrollView scroll endlessly :
- (void)scrollViewDidScroll:(UIScrollView *)theScrollView {
theScrollView.contentSize = CGSizeMake(45, theScrollView.contentSize.height+45);
}
But how can i create the same effect when the user scrolls upward ? I tried to play with the contentInset but then the contentOfsset doesn't get updated and i end up having weird behaviour.
Do you have any idea how i could achieve that ?
I needed the same, so I created this: http://dev.doukasd.com/2011/04/infinite-scrolling-dial-control-for-ios/
Have a look at the video, I believe it's what you're looking for. Source code is included.
I have developed this kind scroll view. It can scroll infinite.
You can check on github: https://github.com/quangrubify/InfiniteUITableView
I think you should give us more details about the issue. What content do you want the user to see when he is scrolling upwards? You increase the contentSize in scrollViewDidScroll method, but you are not checking the contentOffset, so the contentWill be bigger whenever the user scrolls the scrollView (either way, even horizontal if allowed). Since the contentOffset is already at 0, the user cant scroll upwards because there is nothing that the scroll view can show.
I dont know the content of your scrollView, but I have implemented infinite scrolling horizontally. For details, see: https://stackoverflow.com/a/12856174/936957
PS: Do not use "magic numbers", this is a better alternative:
theScrollView.contentSize = CGSizeMake(theScrollView.contentSize.x, theScrollView.contentSize.height+45);
//Or theScrollView.frame.size.width alternatively