UIScrollView without AutoLayout shows horizontal scroll Indicator in iOS 6 but not in iOS 7 - uiscrollview

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.

Related

NSOutlineView strange padding is cropping a badge

I created a view-based NSOutlineView with an image and a badge (an inline button). Although the custom cell is wide enough, I have the following problem:
So there is a strange margin from the right which overlays my badge (the NSOutlineView is embedded in a ScrollView and this in a SplitView).
Any ideas, how I can remove this margin / overlay?
Ok, my last comment brought me the answer ;)
As far as I can see, it's really a problem with the scrollbar, no matter if it's hidden or not. I think it's a relict of older OS X versions, where the scrollbars were permanently shown. When you resize the outlineview (embedded in a scrollview and this embedded in a splitview), the width of the cells automatically will always become a little bit smaller than the width of the outlineview itself (probably because the NSScrollView code thinks, it has to adjust because of the scrollbar).
Therefore I subclassed NSTableCellView (I'm using a viewbased outlineview) and added this:
- (void)setFrameSize:(NSSize)newSize {
//resize the textframe, so that it will not be cropped too early with "..."
NSRect textFrame = self.textField.frame;
textFrame.size.width = newSize.width;
self.textField.frame = textFrame;
//increase the size of the whole cell
newSize.width = newSize.width + 10.0;
[super setFrameSize:newSize];
}
You also have to increase the width of the textframe, because - as you can see in Finder or Mail etc. - the text of the cell is very early cropped (with "..."). By increasing it's width, this problem is also solved.
I hope, this description is nearly understandable ;)

Stop NSScrollView only on specific values - Like UIScrollView paging

I am working on a Mac OS X app using SDK 10.7 as deployment target. A NSScrollView contains a horizontal list of image thumbnails. The thumbnail which is in the center of the ScrollView indicates the selected image which is shown below the ScrollView in full size. This works quite similar the the Finder Cover-Flow, beside that the images in my app do not flow but just scroll away.
I would like to limit the scrolling to stop only when a thumbnail is exactly in the center. The NSView method adjustScroll: is no solution. This would disable "smooth" scrolling and let the ScrollView jump from one thumbnail to the next.
I would need some kind of action/callback which tells me that the ScrollView finished scrolling. I could than check if the position is OK (if a thumbnail is in the center) or scroll back/forward to the closest thumbnail. But NSScrollView does not provide such an callback.
I tried to observe changes of the frame of the ScrollViews contenView. Evertime the frame changes I start a timer. If the timer is not restarted before it fires I assume that scrolling stopped. This does not work very well. If scrolling stopps only for a short time (e.g. because the finger is moved to do another swipe gesture) the next scrolling interferes with the correction of the position.
Using UIScrollView under iOS solves this task without any problem. A similar paging feature for NSScrollView would be a perfect solution.
Does any one know how to solve this?
Thank you very much!
You can use NSScrollViewDidEndLiveScrollNotification:
NSScrollView* scrollView;
const CGFloat interval = 100;
[[NSNotificationCenter defaultCenter]
addObserverForName:NSScrollViewDidEndLiveScrollNotification
object:scrollView
queue:nil
usingBlock:^(NSNotification* notification) {
CGFloat offset = scrollView.contentView.bounds.origin.y;
offset = round(offset / interval) * interval;
[scrollView.contentView.animator setBoundsOrigin:NSMakePoint(0, offset)];
}];
You can use NSAnimationContext to tune the duration and timing of the animation.
Note: According to the docs, this notification was introduced in 10.9, so it wouldn't have been an option for the 10.7 deployment target mentioned in the original question.

Floating UIView on UITableView broken in iOS6

In my app i have UIView that floats at the top of a UITableView (Visualise:Attached to the bottom of the navigation Bar), under iOS5 i was enabling it to float at the top using these lines of code in scrollViewDidScroll
// get the table and buttonView bounds
CGRect tableBounds = self.tableView.bounds;
CGRect buttonViewFrame = self.buttonView.frame;
// make sure the buttonView at the table's original x and y as the content moves
self.buttonView.frame = CGRectMake(tableBounds.origin.x,tableBounds.origin.y,buttonViewFrame.size.width,buttonViewFrame.size.height);
This however no longer seems to work in iOS6, does anyone know why or how to fix the problem? I'm supporting iOS5 and above.
Having looked through the iOS6 release notes i found this...
Note that you can make a subview of the scroll view appear to float (not scroll) over the other scrolling content by creating constraints between the view and a view outside the scroll view’s subtree, such as the scroll view’s superview.
How would I set this up in code as Im not using AutoLayout in storyboards as I'm still supporting iOS5. It would also be great if anyone can enlighten me as to why the code i was using in iOS5 no longer works in 6.

How to make only vertical scroll view?

I already read this one:
http://api.three20.info/interface_t_t_scroll_view.php
But it seems like there is no property for vertical scroll only. However based on the:
http://three20.info/gallery
There are few apps that has "vertical-scroll-only" apps, like the facebook apps. In the facebook app, you can keep vertically scroll to view the latest status/posts/images from your friends, I was wondering if they use TTScrollview or UIScrollview.
Whats the correct way of displaying the "vertical-scroll-only" view in Three20 framework?
Please advise, thanks !
Facebook is most likely using TTTableView for displaying the status updates view in the Facebook app.
TTTableView inherits UITableView, which only scrolls vertically.
Whether you're using Three20 or not, a simple way to implement a vertical only scroll view is to use UIScrollView.
To make a UIScrollView "vertical-scroll-only" you would set the width of the contentSize property to less than or equal to the width of your scroll view, while its height needs to be greater than your scroll view's height to allow for vertical scrolling.
UIScrollView *yourScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
yourScrollView.contentSize = CGSizeMake(320, 210); // <-- sets the scrollable area
yourScrollView.backgroundColor = [UIColor grayColor];
[self.view addSubview:yourScrollView];

setFrame created an NSView that is 15 pixels smaller in both dimensions than expected

I have a puzzling problem. I have a pointer to a vanilla NSView that was initialized in a nib. I messaged the NSView with:
[myNSView setFrame:NSMakeRect(0,0,816,1056)];
but when I step through the debugger, myNSView has a frame of {{0,0}, {801, 1041}}. The dimensions of the rectangle are 15 less than I've specified! This happens consistently. If I specify two [setFrames] in a row, everything works, but of course that's not the answer.
Why does setFrame fail?
15px is exactly the size of an NSScroller at NSRegularControlSize.
My guess is that you have your NSScrollView configured to automatically hide scrollers.
Try turning off the horizontal and vertical scrollers of your scrollView in the NIB, if that solves the problem, you'll know where to look from there.  It is something related to the clipView of the scrollView autoresizing the documentView. The clipView itself is being autoresized when the scrollers appear; directly after you set the documentView to a frameSize (the 100% setting I'd guess) that requires scrollers.

Resources