When I set the vertical scrollbar indicator to NO, it also hides the horizontal scroll bar in iOS7
scrollView.showsVerticalScrollIndicator = NO; -> hides also horizontal bar as wel
Related
I wanted to show the UIScrollView's scrollbar only when needed, i.e. when the content exceeds the visible size and needs scrolling to see everything.
So I added this code:
self.view.addSubview(self.myScrollView)
self.myScrollView.edgesToSuperView()
print(self.myScrollView.contentSize.height)
print(self.myScrollView.bounds.height)
if self.myScrollView.contentSize.height > self.myScrollView.bounds.height {
self.myScrollView.showsVerticalScrollIndicator = true
}
However, contentSize.height and contentSize.height always print out as zero, although that inside the scrollView there is a stackView that has many text labels that exceeded screen height. So this didn't worked out.
Any better ideas?
This property:
.showsVerticalScrollIndicator = true
only controls the visibility of a scroll indicator while the user is scrolling.
By default, if your content is not "tall enough" to need to scroll, the scroll indicators are never shown.
If your content IS "tall enough" to need to scroll (height is greater than the scroll view's frame height), the scroll indicators are shown while scrolling.
There is no way to have them "always showing."
If you want to indicate to the user that there is more content to be seen by scrolling, you could add something like "arrows" that you show / hide as appropriate, or, you can call `self.myScrollView.flashScrollIndicators() to "flash" the scroll indicators.
My Mac app uses a floating window without a title bar that can be moved by dragging.
NSRect frame = NSMakeRect(500, 950, 600, 100);
self.lbWindow = [[lbCustomWindow alloc] initWithContentRect:frame
styleMask:NSWindowStyleMaskBorderless
backing:NSBackingStoreBuffered
defer:NO];
[self.lbWindow setOpaque:NO];
[self.lbWindow setBackgroundColor:[NSColor clearColor]];
[self.lbWindow setHasShadow:YES];
[self.lbWindow setReleasedWhenClosed:FALSE];
However, this window can't be placed (eg created at that position), or moved (by dragging) to just under the top menu bar, it can only get to about 30px below it - it's exactly the height of a normal window title bar - basically, the window seems to be vertically constrained as if the window had a title bar.
(The Y co-ord "950" is the highest I can place the window, which results in the image below.)
I'd like this to act as though there was no title bar, and be able to place it so the top edge of the window is just below the menu bar.
(I haven't included the custom window implementation, but there's not much in there apart from dragging support - and it's not the dragging that's causing the constraint, as is still applies when you just initially position the window programatically.)
Thoughts?
Ok, just after posting I've found out why (typical). :)
The (transparent) window is created ok, but when I add the subview to it, for some reason (refactored old code) it's being added a title bar's height lower than the top of the window.
(It's obvious when you make the window non-transparent).
So just need to reposition the view and I should be fine.
I spent several days trying to see the working UIScrollView horizontal scroll indicator (without AutoLayout) on iOS7 (on iPad). But without success.
Has anyone fixed such bug?
My project is simple and running iOS5 and iOS6 without troubles.
I found out, that on iOS7 height of the scroll indicator image is always zero:
UIImageView * scrollBar = [[scrollView subviews] lastObject];
if (scrollBar != nil)
{
PrintRect(#"FRAME", scrollBar.frame);
PrintRect(#"BOUNDS", scrollBar.bounds);
}
Result for iOS7:
FRAME x:0.000000 y:54.000000 w:338.000000 h:0.000000
BOUNDS x:0.000000 y:0.000000 w:338.000000 h:0.000000
but for iOS6:
FRAME x:0.000000 y:47.000000 w:338.000000 h:7.000000
BOUNDS x:0.000000 y:0.000000 w:338.000000 h:7.000000
So the height scroll bar image on iOS7 is equal to zero.
It's possible to change the height, but only for a quick time because during drugging the height becames zero again.
I was stuck on something similar. I am doing the CS193P course on iTunes and there was this scrollView exercise - Imaginarium. Basically it's just a UIImageView embedded in a UIScrollView. I was having the same problem that the scroll indicators were not being displayed (with Autolayout turned off)
I looked up the header file for UIScrollView in the documentation and there is this property in scrollView called scrollIndicatorInsets:
The distance the scroll indicators are inset from the edge of the scroll view.
#property(nonatomic) UIEdgeInsets scrollIndicatorInsets
It goes on to say that the default value is UIEdgeInsetsZero!! So I created a UIEdgeInset using UIEdgeInsetsMake (see documentation). Then in viewDidLoad I set this UIEdgeInsets to be my scrollView's scrollIndicatorInsets, after which my indicators appeared when I scrolled.
Hope this works for you too.
I define a UILabel inside a UIScrollView in my ipad.
But how to display the UISrcollView vertical Bar when the text is bigger than the scrollView ?
When I touch the scrollView the vertical bar appeared, but how to display it without touching ?
Regards
Fred
I think, its not possible. Setting showsVerticalScrollIndicator and showsHorizontalScrollIndicator properties you can display the scroll bar.
You can use flashScrollIndicators when the view becomes visible. It will guide user that scrollable content is available.
I have created a custom title bar view for a blackened NSWindow (style 0), so that I can have it disappear in a similar manner to Quicktime X. The only problem is, the buttons don't respond to mouse over and mouse move actions on the title bar can get combined with pressing in the buttons.
The full source code is here: https://github.com/iaefai/OrganicUI under Classes/ORTitleBar.m and ORWindow.m.
The buttons are standard from this method:
self.closeButton = [NSWindow standardWindowButton: NSWindowCloseButton
forStyleMask:NSTexturedBackgroundWindowMask];
Then positioned:
[self.closeButton setFrame: __frame];
Then added to the titlebar:
[self addSubview: self.closeButton];
A small video of the disappearing title bar can be seen here:
http://web.me.com/iaefai/OrganicUI/ORWindow.html