uiscrollview

Setting contentOffset programmatically triggers scrollViewDidScroll

痞子三分冷 提交于 2019-12-17 15:19:25
问题 I've got a a few UIScrollView on a page. You can scroll them independently or lock them together and scroll them as one. The problem occurs when they are locked. I use UIScrollViewDelegate and scrollViewDidScroll: to track movement. I query the contentOffset of the UIScrollView which changed and then reflect change to other scroll views by setting their contentOffset property to match. Great.... except I noticed a lot of extra calls. Programmatically changing the contentOffset of my scroll

How can I get the UITableView scroll position so I can save it?

淺唱寂寞╮ 提交于 2019-12-17 15:15:21
问题 Is there any way to find out which UITableViewCell is at the top of the scroll window? I'd like to get the current scroll position so that I can save it when the app exits. When the app gets started I want to scroll to the position it was at when it last exited. 回答1: You can easily grab the exact offset of the table view by looking at its contentOffset property. For the vertical scroll, look at: tableView.contentOffset.y; 回答2: The accepted solution only works if you know the size of all table

Limiting the scrollable area in UIScrollView

随声附和 提交于 2019-12-17 11:09:11
问题 I have a UIScrollView that is scrolling a fairly large UIView. At certain times I want to limit the area the user can scroll around in. For example, I may only want to allow them to view the bottom quarter of the view. I am able to limit the area by overriding scrollViewDidScroll and then calling setContentOffset if the view has scrolled too far. But this way I can't get it bounce back as smoothly as the UIScrollView can naturally do when scrolling beyond the bounds of the UIView. Is there a

Memory leak every time UIScrollView is released

可紊 提交于 2019-12-17 09:52:25
问题 In my app I have a scroll view and four table views. Each time one is dragged and then released, I get a 48 byte leak. This really adds up. As you can see, both groups of leaks have the same source. Has anyone seen a leak like this before? Edit 1: When I click on the arrow next to the leak, I get this information for the leak: 回答1: What you are seeing is a known bug in iOS 5.1 and is being discussed in the iOS Developer Forums as such. You can find the relevant thread by searching in the

Memory leak every time UIScrollView is released

╄→гoц情女王★ 提交于 2019-12-17 09:52:01
问题 In my app I have a scroll view and four table views. Each time one is dragged and then released, I get a 48 byte leak. This really adds up. As you can see, both groups of leaks have the same source. Has anyone seen a leak like this before? Edit 1: When I click on the arrow next to the leak, I get this information for the leak: 回答1: What you are seeing is a known bug in iOS 5.1 and is being discussed in the iOS Developer Forums as such. You can find the relevant thread by searching in the

Getting the visible rect of an UIScrollView's content

你。 提交于 2019-12-17 08:06:05
问题 How can I go about finding out the rect (CGRect) of the content of a displayed view that is actually visible on screen. myScrollView.bounds The code above works when there's no zooming, but as soon as you allow zooming, it breaks at zoom scales other than 1. To clarify, I want a CGRect that contains the visible area of the scroll view's content, relative to the content. (ie. if it's a zoom scale 2, the rect's size will be half of the scroll view's size, if it's at zoom scale 0.5, it'll be

UIScrollView contentSize not working

戏子无情 提交于 2019-12-17 06:33:28
问题 I put a UIScrollView in my nib's view , and linked it to a an IBOutlet property. Now, when I do this in my viewDidLoad method, it seems to have no effect on the contentSize : self.sv.backgroundColor = [UIColor yellowColor]; // this works CGSize size = CGSizeMake(1000.0, 1000.0); [self.sv setContentSize:size]; // this does not It behaves as if the contentSize was the same as the frame. What's going on? This started working when I turned off AutoLayout. Why? 回答1: I had the same problem. Auto

ScrollView not scrolling when dragging on buttons

五迷三道 提交于 2019-12-17 06:26:13
问题 I have a scroll view that used to scroll when it didn't have buttons all over it. Now it does, and when dragging the mouse (on simulator) nothing happens (i think because the buttons are being pushed). How can I make this right? 回答1: This is happening because UIButton subviews of the UIScrollView (I assume buttons are added as subviews in your case) are tracking the touches and not the scroll view. UIScrollView method touchesShouldCancelInContentView is the key here. According to its

UIScrollview getting touch events

牧云@^-^@ 提交于 2019-12-17 06:25:25
问题 How can I detect touch points in my UIScrollView ? The touches delegate methods are not working. 回答1: Set up a tap gesture recognizer: UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)]; [scrollView addGestureRecognizer:singleTap]; and you will get the touches in: - (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture { CGPoint touchPoint=[gesture locationInView:scrollView]; } 回答2: You can make your

Animation in OpenGL ES view freezes when UIScrollView is dragged on iPhone

不打扰是莪最后的温柔 提交于 2019-12-17 05:49:06
问题 I have an animated transparent OpenGL ES subview (a modification of Apple's template EAGLView class) which draws a rotating sphere. Just like Apple's example, CADisplayLink is used on devices where available. On the same screen, there is a UIScrollView containing UIButtons that can be selected. When the user scrolls the UIScrollView, the animation of my EAGLView freezes. This behavior is reproduced on iOS Simulator 4.2 and on iPhone OS 3.1.3 on an iPhone 2G device. Any ideas on what to do to