accessing delaycontenttouches property of uiscrollview - iphone

Since uitableview inherits from uiscrollview, would i have access to the delayContentTouches property of UIScrollView from my table view controller? I thought I could do something like the following, but it doesn't work(self is the UITableViewController):
self.view.delayContentTouches = YES;
Thanks.

If the value of this property is YES, the scroll view delays handling the touch-down gesture until it can determine if scrolling is the intent. This value is YES by default. You'd better tell what do you want to do?

Related

How to get the contentOffset of a UIScrollView mid-scroll?

How would one get the contentOffset or similar information about a UIScrollView while the user is still scrolling? For example if I wanted to place an image as a header right above the content of a UIWebView, without the image being part of the WebView's scrollView, but have it update while the user scrolls, not just jumping to the position after they let go. How could I go about doing this?
In iOS 5, the UIWebView has a scrollView property which is the UIScrollView responsible for handling the scrolling. Prior to iOS 5 you can search the UIWebView's subviews property for the subview using [subview isKindOfClass:[UIScrollView class]].
Once you have the UIScrollView, you can then set its delegate property. In the delegate you can then respond to the scrollViewDidScroll: message when the user scrolls, and update the position/contents of your header view.
Added: 29/2/2012 - In order to preserve the UIWebView's functionality, you will need to forward your intercepted UIScrollViewDelegate methods to the UIWebView too. To do this, you can call the UIWebView at the end of all mandatory methods within the protocol and implement something like forwardInvocation: or forwardingTargetForSelector for the optional protocol methods. This will preserve your original UIWebView behavior and allow you to enhance it with your own logic.
Why can't you just put the header as a separate view above the UIWebView? Why does it have to be a subview?

UIView behind cells of a UITableView

I'm trying to insert a view behind the cells of a uitableview but I can't find a way to do it properly. Everytime I add a subview to self.view or self.tableview, it goes on the foreground, even if I use the method "sendSubviewToBack:" ...
Do someone have an idea on how to achieve it ?
PS : I don't want to use self.tableview.backgroundView because the view is fixed.
Thanks
I solved it by calling [self.view sendSubviewToBack:self.myBackgroundView] in tableView:willDisplayCell:forRowAtIndexPath:. This will put the view behind each cell.
What you experience is logical. The self.view of a UITableView is indeed the table view. If you insert a subview, it is inserted on top of the table view - and there is no way to send it to the back.
Solution 1
The most flexible solution is to switch to a UIViewConntroller and implement the table view behaviour yourself. You need to
insert your own table view as a #property. This is now a subview of self.view. You can do this in code or in IB.
declare and implement the <UITableViewDelegate> and <UITableViewDatasource> protocols
set the delegate and datasource properties of the table view to self
insert any other subviews at will and shuffle them around as you wish.
Solution 2
If you just want to display something behind the tableView you might be able to use the table view property backgroundView. This will display behind the cells, but you will have limited control over the view's size (which you could again solve with further subviews of the background view). Also, you need to make sure your cells are transparent.
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index
with index 0 will take the View to position which is the back-most one.
This is a method on UIView.
Since UITableView Inherits from UIScrollView : UIView : UIResponder : NSObject. I guess this would help.

Touch on UIButton in a UITableViewCell cannot scroll the table

I need to have a UIButton inside a UITableViewCell, everything works fine except when I touch inside the button and move my finger, the table does not scroll.
I tried to subclass UIButton and in touchesMoved: method send the same message to self.nextResponder, or call touchesCancelled and hope it will pass the touch event to next responder, they both do not work.
Is there any good way to solve this problem? Currently I am adding a UIView on top of the UITableViewCell, and detecting touch events manually, passing result to the button or the rest of the cell respectively, but this is a little bit dirty.
What you can try is setting the delaysContentTouches property of the UITableView to YES.
Additionally you can set the canCancelContentTouches to YES.
If the value of this property is NO, the scroll view does not scroll
regardless of finger movement once the content view starts tracking.
Source: UIScrollView Class Reference
Try:
_yourTableView.delaysContentTouches = YES;
_yourTableView.canCancelContentTouches = YES;
The best way is to make a custom cell and do your work neatly.
Check the Apple docs

Integrate an UIScrollView to an existing view

I have a View in a xib file and a corresponding ViewController.
With Interface Builder I put an image, some labels and now a table view in it.
What I want to have, is that the whole view will be scrollable, because the new table view is currently only scrolling inside the tableview boundaries.
How can I put a scroll view behind this existing view with IB?
I already put a UIScrollView to the IB and put all other elements on it. Also I create an UIScrollView IBOutlet and connect it, but the screen is not scrollable...
Do I have to do something like
[myScrollView addSubview: ???];
Thank you a lot in advance & Best Regards.
You need to set the contentSize property of the scrollview before it is usable. Yeah, I know - freaking ridiculous that this isn't automatic.
Just do myScrollView.contentSize = CGSizeMake(int, int).

Accessing superview ScrollView?

i added some views (every view has its own viewcontroller and nib) to an UIScrollView. How can I access the ScrollView from within the UIViews I've added?
self.view.superview doesn't get me the UIScrollView properties. I need to disable scrollEnabled from within an UIView.
Thank you!
Maybe try (UIScrollView*)(self.view.superview).property to access the property you want :-)
It should work.
But maybe with an Delegate it would be better :-p
Good Luck !