When creating a custom delegate for a ListView, the height of the cells changes. How to fix it? - nativescript

I tried to make custom delegate for ListView in NativeScript to track scrolling. When trying to change the height of cells via CSS or directly in the tag, something strange is happening with the height of the cells. If i remove the delegate then everything is fine.

Related

NSTitlebarAccessoryViewController and hidden property

Recently 'discovered' NSTitlebarAccessoryViewController and love it -
except I need my apps to work under 10.11 and the hidden property doesn't exist until 10.12.
Any suggestions how to smoothly show/hide an NSTitlebarAccessoryViewController instance before 10.12, i.e. animate the view out/in?
I've tried adding a height constraint and animating it (i.e. the constraints constant property - but NSTitlebarAccessoryViewController automatically gets an auto resize constraint (even when turning it off before inserting the view) that causes Auto Layout exceptions as it forces the view to its initial height and prevents changing it..
Changing the view's frame property via the animator proxy also doesn't result in an animated change of the view's height.

What is the proper way to implement contentview with constraints in a scrollview in xcode using autolayout?

Recently I'm testing to do a very complicated view in xcode using nothing but scrollview and programatically added imgviews. Like this
What I did is, I put a UIView called contentview in a scrollview and I then add a lots of ImageViews in the contentview. The real thing is much much complicated than the illustration so I can't use tableview. Sorry for the poor illustration but I think you will get the idea.
Everything is fine until I tried to add the last constraint in code, which marked red in the picture. When I did it, it breaks the entire chain of constraint.
In another word, this is working
V:|-[view1(30)]-[view2(30)]-[view3(30)]
This is not
V:|-[view1(30)]-[view2(30)]-[view3(30)]-|
And btw, what is the proper way to do it anyway? I tried to add imageviews directly into the scrollview itself but I can't make the view to use autolayout like this
H:|-[view]-| The superview here is a scrollview
The result, this view will be very narrow in width. I guess scrollview doesn't have a width value or sth? that's my guessing. That's why I added a contentview as a holder for all the imageviews.
Try this, it will work. - http://natashatherobot.com/ios-autolayout-scrollview/
To summarize -
Add scroll view to main view.
Add a UIView (lets call it content view) to scroll view.
Now add all your views to the above UIView.
For each of them set the constraints so as the separation on all sides is 0. And finally add equal height and equal width constraints between the content view and the main view.
Ok, finally I did my own work.
The key to make scrollview and contentview and everythin else inside work automatically using nothing but autolayout is this.
1, Manually add scrollview to self.view, and a contentview to scrollview. Set both scrollview and contentview to setTranslatesAutoresizingMaskIntoConstraints(false)
2, set scrollview to H:|[scrollview]| and V:|[scrollview]|, set contentview to be H:|[contentview]| and V:|[contentview]|
3, Now try to add Views to content view and set their constraints to the contentview. You should see that when the views are larger than the current window size, the scrollview started to scroll. IE, this setting will automatically set the scrollview.contentSize using autolayout

NSScrollView blur in NSPopover

I have a couple of NSScrollViews inside an NSPopover in my app. I want to create a Safari-like blur with scrolled content on the top. However I can't find any solution, since it is an NSPopover and I cannot set the style mask. I tried adding a blank row with the height of the header and positioning the header (NSVisualEffectView) over the NSScrollView (table view), and this method works but the scroller goes under the header. So is there a "right way" to do it?
NSScrollView provides a nice method called addFloatingSubview:forAxis:. It should be possible to add the NSVisualEffectsView as a subview of the scroll view then. By using this method, the scroller stays above the header.
To get the scroller stop before the effects view, you can modify the contentInsets property of NSScrollView.

NSCollectionView inside NSTableCellView doesn't resize

I want to show a NSCollectionView inside a NSTableCellView. I have it setup correctly, and it works for the most part, but the collectionView's scrollview doesn't seem to resize properly against the NSTableCellView, even though I have auto-layout constraints setup for this.
Is there anything I can do to setup constraints in a way that the scrollview resizes against the NSTableCellView (which should also let the collectionView also resize itself)?
EDIT:
To elaborate, what I really want to do is have the collectionView expand and resize as the window is resized, and have it take up the same width as the tableViewCell, and depending on the number of items in the collection view, resize the height of the outlineView & hence determine the height of the outlineView's row. It works fine when the collectionView is part of an ordinary view, but I can't get it to resize itself inside a NSTableCellView.
Firstly, remove all of the constraints you've set for your collectionview/scrollview.
Now, you will need to make 4 constraints, one for each of the leading, trailing, top and bottom space from the scrollview to its superview. Make sure width and height are not constrained. I've done this in a recent app I've made and it worked rather well.
EDIT: Below in the comments we figured out the column wasn't resizing so the constraints were correctly set.

detect scroll in horizontally uitableviewCell

I have UiTableView containing some data, and I want to scroll the UiTableViewCells horizontally to the left or right to show some UiButtons that act some action relatif to the content of the cell.
How Can I do this?
I'm thinking in creating custom cell, and putting a scrollView in it, May this did the trick?
There is a tutorial for this at http://idevrecipes.com/2011/04/14/how-does-the-twitter-iphone-app-implement-side-swiping-on-a-table/ with sample code. He is using a UISwipeGestureRecognizer to trigger an animation that pushes the cell off the screen.
You could use a swipe gesture recognizer attached to your cell.
You can add a UIScrollView to the contentView of a UITableViewCell. If you want to scroll the content using buttons, simply overlay the UIScrollView with buttons and make them call the various scrolling methods of UIScrollView.
Nested UIScrollView (UITableView inherits from UIScrollView) are quite clever about detecting touch conflicts and resolving the users intended gesture.
https://github.com/JonasGessner/JGScrollableTableViewCell might be what you're looking for. It implements this using a UIScrollView inside the cell (just like the iOS 7 mail app).
(Yes the answer is a bit late, but it's never too late! :P)

Resources