UIScrollView has its own dot indictators? - iphone

I have a ViewController with a view that contains a ScrollView and a PageControl positioned at the bottom.
What I noticed however, is that the ScrollView already has its own set of 3 dot indicators. So, just for the sake of testing, if I move around my PageControl bar, I can actually see two sets of dot indicators.
I have my IBOutlet set to my PageControl, so the dots get updated as I'd expect. However, the dots on the ScrollView don't change (and there are always 3 of them).
Why does the ScrollView already have its own dots? I tried unchecking "Show horizontal scrollers" but this did not get rid of the dots.
I guess why question is two-fold: How could I remove the dots from the ScrollView since I really only want the PageControl? Secondly, what is the purpose of having those dots on the ScrollView itself?
To be clear, I've already unchecked the Show horizontal and vertical scrollers in Interface Builder. I have also disabled them programatically:
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
Thank you in advance!

The UIScrollView does not have dots. Maybe you added two UIPageControls accidentally. If you show more code maybe we can help but all I can tell you is that a UIScrollView is not the source of the dots.

Related

Can not swipe when iCarousel contains UITableView as subview

Hi I am using iCarousel in my application, it will have UITableView as subview. When i am trying to swipe or pan to display next or previous item it is not working. I think UITableView's gesture recogonizer disables the iCarousel's gesture recogonizer. There are so many questions like this but i do not see any answer for this. attched is sample image
Please guide me to fix this.
code
_carousel =[[iCarousel alloc]initWithFrame:self.view.frame];
_carousel.type = iCarouselTypeLinear;
_carousel.pagingEnabled = YES;
_carousel.delegate = self;
_carousel.dataSource = self;
[self.view addSubview:_carousel];
It looks like your carousel isn't centered which makes me think that maybe its bounds are wrong.
iCarousel doesn't have clipsToBounds enabled by default, which means that if the bounds are wrong, you will still see your item views, but may not be able to interact with them.
Try enabling clipsToBounds on the carousel, and setting the backgroundColor to something like red, so you can see if the carousel dimensions are correct.
If they aren't you may need to adjust your autoresizing or autolayout constraints.
UPDATE:
This was actually a bug in iCarousel relating to the heuristic it uses to determine if swipe gestures should be intercepted by the carousel. Fixed in beta 7.

Hiding elements outside of bounds on iPhone

I'm trying to get a UIView to expand (with animation), sort of like an accordion menu. I can get the animation working fine however the issue is the subviews of the UIView are expanding past the bounds of the UIView.
For example, the view has an UILabel in the top-right corner with a height of 16. Assume the UIView height is 0 at the beginning of the animation. One would expect that the content of the view be hidden and gradually reveal as the UIView grows. Once the height has reached 8, for example, half the label should be visible. However that isn't the case - rather, the label is visible the whole time, regardless if it's height extends outside of that of it's parent view.
Any ideas how to resolve this?
Okay, I had to set the clipsToBounds property to true. I spent some time googling before making the question but didn't have much luck until I saw it in the Related section of my question.

Is there a way to put UITextView's scroll indicator to outside UITextView?

It might be a silly question.
I'm trying to set left/right margins like the attached picture. I succeeded to implement it by adding UITextView to UIScrollView.
However, I could achieve almost everything I want with UITextView alone. For example, with UIScrollView, when I manually change the text of UITextView, it automatically scrolls to bottom regardless of setting its .scrollEnabled to No.
It would be perfect if a scroll indicator of UITextView appears outside UITextView.
In the attached picture, let's say the red box represents the entire UITextView. I tried to change UITextView's scrollIndicatorInsets property, but a scroll indicator can be moved only inward to be visible.
Several apps such as Pages, aWriter, Plaintext achieve this feature.
Could you give any suggestion?
Thank you!
I
You can set the scroller right inset value of the UITextView to negative value and disable the clip subview option to achieve your require. No other scrollview is needed.
Alternatively you could set the Right contentInset property.
UIEdgeInsets insets = textView.scrollIndicatorInsets;
insets.right += 5; //add what ever is your margain
textView.scrollIndicatorInsets = insets;

Iphone Custom Scrollview indicator

I am currently working on an application for a client, and they have made an odd request. The request involves putting a custom image as the indicator for the scrollview. I am not even sure if this is possible but if it is can you please let me know how one would go about doing that.
Thanks
UIScrollView streches a small, semi-transparent circle image to generate its scrollbars. You can find this image as the first subview of a UIScrollView:
UIImageView *circle = [scrollView.subviews objectAtIndex:0];
However, as I said this image is stretched, and as far as I can tell, only the alpha values are considered when drawing the scroll bars.
So for example if you're only interested in changing the top/bottom ends of the scroll bar, you can try to change this image. However, I doubt you'll be able to do anything interesting.
A possible solution that comes to mind, and this is only a theory, is to add a custom, transparent UIView on top of a UIScrollView. Then you can hide the default scroll bar (by using showsHorizontalScrollIndicator and showsVerticalScrollIndicator), pass the necessary touch events to the UIScrollView to scroll the content, and draw the scrollbars in your custom view.

UIScrollView not showing scroll indicator

I have a UIScrollView which I create and size dynamically using...
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width , length);
I then add subviews to the UIScrollView.
I do have scrollView.showsVerticalScrollIndicator = YES;
When scrolling the scroll indicator never appears.
Even if I call [scrollView flashScrollIndicators] nothing happens.
Ideas?
Had the same problem and couldn't find the cause. The last answer gave the final hint: whenever I added new subviews I first removed all existing subviews from the scrollview (and apparently also the scroll indicators).
After checking in my loop, if the subview really was of the kind I wanted to be removed the scroll indicators showed up:
for (NSObject * subview in [[[scrollView subviews] copy] autorelease]) {
if ([subview isKindOfClass:[MySubView class]]) {
[(MySubView*)subview removeFromSuperview];
}
}
Update: changed code to Nikolai's suggestion
When I've dealt with this before, in my implementation of a grid, I would occasionally get some cells over the top of the scroll indicator. To fix this I am now inserting subviews at index 0 rather than adding them, which adds them to the top. So try something like this:
[scrollview insertSubview:subview atIndex:0];
For me, the horizontal indicator had mysteriously disappeared in my app on iOS 7. Later found out that for some strange reason, I had to enable both Shows Horizontal Indicator and Shows Vertical Indicator to make the horizontal one show up. If I set it to not show the vertical indicator, it would also not show horizontal indicator.
I fix this by adding this code after add new subview:
self.showsVerticalScrollIndicator = NO;
self.showsVerticalScrollIndicator = YES;
It will also happen (at least in the case of a UITableView) if the contentSize is too small for the table view to scroll. If you have enabled bouncing, then the tableview does not actually scroll and does not display the indicators therefore. Try fitting more content inside.
It can happen also if the parent of the scrollview is smaller horizontally than the scroll view itself :
The scroll bar is stuck to the right side of the ScrollView / TableView and this right side is not visible due to the parent bounds ( with a clipToBounds hidding it for instance).
I've seen this issue so I share it in case it can help.
Just check the width of your ScrollView's frame not to be bigger than the width of its parent view frame.
Two conditions,
If you are using a storyboard
If you are using a UITableView inside a UIViewController
Then, you should check your indicator insets are set to 0 (or any other number that is relevant to your autolayout):
Noticed this when the UIScrollView was a 48 px tall horizontal band, scrollable horizontally. Maybe Cocoa decides the area is too small for a scroll indicator...