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.
Related
Has anyone gotten multi-touch zoom to work on a textView?
I have searched SO and found no simple way to zoom in on a UITextView or UIScrollView. I was led to this link which says I need to write custom views to overwrite the existing ones in order to be able to zoom in to a textView. I can not believe this and would like someone to please let me know if there is a simple way to zoom in and zoom out using multi-touch on a UITextView or a UIScrollView.
I tried setting the options in the IB to enable multi-touch as well as the max zoom. But this does not work.
Please advise. Thank you.
1 Create a new project with single view (using storyboard & arc)
2 Open Storyboard and add a UIScrollView to your main view controller
3 Set the UIScrollView's delegate to the view controller and create an IBOutlet for the UIScrollView called scrollview
4 Add a UITextView to the scrollview and set an IBOutlet called textview
5 At the end of the ViewDidLoad add the following code:
self.scrollview.minimumZoomScale = 0.5;
self.scrollview.maximumZoomScale = 5.0;
self.textview.text = #"Hellow World!";
6 Add the following method
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self.textview;
}
7 Run the project and zoom away!
If you want the text to look not render blurry when use the answer at this Blurry UITextField Question
The UIScrollView class provides support for displaying content that is larger than the size of the application’s window. It enables users to scroll within that content by making swiping gestures, and to zoom in and back from portions of the content by making pinching gestures.
By adding your UITextView to a UIScrollView, you can implement muti-touch zoom.
I am resolving to answer this question myself with the assumption that this is not possible at this time. With a textArea I have found no way to zoom in on the text. I have not found any tutorial or example that shows this is possible.
I've got a UIScrollView (scrollView) and a UIImageView (scrollImage). I'm trying to add buttons to a scroll view and have them resize and reposition correctly when I zoom in and out. I had the following code at first to add a button:
[scrollView addSubview:button];
This gave me problems with zooming in and out. The position of the buttons wouldn't stay relative to the image. So i changed it to this:
[scrollImage addSubview:button];
Which made everything zoom in and out nicely, however the buttons have stopped reacting to touches (I assume because they are beneath the UIScrollView).
Is there a way to have both features working correctly?
Thanks
Zac
By default a UIImageView has userInteractionEnabled set to NO. Set it to YES and you should be fine.
try by setting like this,
scrollImage.userInteractionEnabled=YES
I'm developing an image viewer, much like the Photos App.
It's a UIScrollView with paging enabled with images loaded from the internet, so I've adapted portions of the LazyTableImages sample. The Scroll View and each ImageView inside of it have all of their autoresize mask flags set.
When I first observed how resizes were happening during rotation, it looked good, but once I started trying to interact with the scroll view, I realized that I also had to programmatically change the size of the contentView. I did that by implementing didRotateFromInterfaceOrientation: in my view controller.
[self.scrollView setContentSize:CGSizeMake(numberOfImages * portraitWidth, [scrollView bounds].size.height)];
With interaction behaving properly, I then discovered that, if I was viewing the second photo and rotated, portions of both the 1st and 2nd photos would be shown on the screen. I needed to change the contentOffset as well.
I've tried to fix this two ways - both by using the scrollRectToVisible:animated: method of UIScrollView, as well as trying to set the contentOffset property directly. And I've experimented by putting this code in implementations of both the "one-step" and "two-step" responses to changes in Orientation. For example:
-(void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
[self.scrollView setContentOffset:CGPointMake(currentlyViewedPhotoIndex * largeImageHeight,0) animated:YES];
In all cases though, it just looks janky as hell. Either I clearly see the scroll happen, or it just jumps. Uuuuuuuuuuugly! Is there a way to do this so that it behaves exactly like the Photos app does?
What I wound up doing instead - just before rotation starts, hide the UIScrollView and create a UIImageView that contains the currently viewed image. Rotate, that image will rotate all nice and pretty, and when rotation completes remove the ImageView and unhide the Scroll View.
Update - if you're reading this today (anytime after iOS 6), use a UIPageViewController and set transitionStyle to UIPageViewControllerTransitionStyleScroll, for crissakes.
I did something slightly different when faced with the same problem. In willRotateToInterfaceOrientation:duration:, I hide all of the UIScrollView's subviews except for the currently displayed subview, and in didRotateFromInterfaceOrientation: I unhide the subviews.
I have a UIScrollView contained within a custom UIView with a content size larger than the ScrollView's frame.
I am able to drag scroll as I expect, but the thing doesn't give me the rubber banding effect that you get with the UITableView or UIWebView. It just stops when you get to one of the extremes.
I have set bounce = YES, is there something else I'm supposed to do?
I read the docs, and they say I have to implement the delegate. I did that.
They also say I should change the zoom levels, but I don't want the user to actually be able to zoom so I haven't set these.
For anyone that finds this thread later, if you are subclassing UIView and re-setting the UIScrollView's frame on every layoutSubviews, that is the problem - it cancels the bounce:
http://openradar.appspot.com/8045239
You should do something similar to this:
- (void)layoutSubviews;
{
[super layoutSubviews];
CGRect frame = [self calculateScrollViewFrame];
if (!CGRectEqualToRect(frame, self.scrollView.frame))
self.scrollView.frame = frame;
}
I had the same problem, on a UIScrollView that wasn't all filled up (but I still wanted it to bounce). Just setted:
scroll.alwaysBounceVertical/Horizontal = YES;
And it worked as expected
It turns out that keeping the UIScrollView within my custom UIView was causing the trouble.
Once I switched my custom UIView to instead inherit from UIScrollView, then the bouncing started working.
That is interesting... Is there a lot going on while the user scrolls the scroll view? Maybe that could cause the problem. The iPhone can multitask, but not too much. Can I see your entire code having to do with the scroll view?
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.