{"id":1395,"date":"2011-05-17T20:53:48","date_gmt":"2011-05-17T18:53:48","guid":{"rendered":"http:\/\/blog.fh-kaernten.at\/wehr\/?p=1395"},"modified":"2012-02-02T08:10:54","modified_gmt":"2012-02-02T07:10:54","slug":"three20-use-tttableview-within-ttscrollview-addition","status":"publish","type":"post","link":"https:\/\/blog.fh-kaernten.at\/wehr\/2011\/05\/17\/three20-use-tttableview-within-ttscrollview-addition\/","title":{"rendered":"Three20 how to use TTTableView within TTScrollView addition"},"content":{"rendered":"<p id=\"top\" \/>In a current project I came across the situation that I wanted to implement a cool TTScrollView with a few TTTableViews in it.<\/p>\n<p>For some reason in my version of the current <a href=\"http:\/\/three20.info\/\">Three20 <\/a>branch the TableView was receiving the &#8220;up and down&#8221; touch events but the parent view (TTSscrollView) didn&#8217;t get any touch events. Googeling give me the result that some of you had the same problem but I couldn&#8217;t find any solution for the problem.<\/p>\n<p>So I came up with the following solution for the problem.<\/p>\n<p>I added a new category TTTableView+TouchesMoveAddition:<\/p>\n<pre class=\"brush:obj-c\">\/\/ UI\r\n #import \"Three20UI\/TTNavigator.h\"\r\n #import \"Three20UI\/TTStyledTextLabel.h\"\r\n #import \"Three20UI\/UIViewAdditions.h\"\r\n\r\n\/\/ UICommon\r\n #import \"Three20UICommon\/UIWindowAdditions.h\"\r\n\r\n\/\/ Style\r\n #import \"Three20Style\/TTStyledNode.h\"\r\n #import \"Three20Style\/TTStyledButtonNode.h\"\r\n #import \"Three20Style\/TTStyledLinkNode.h\"\r\n\r\n\/\/ Core\r\n #import \"Three20Core\/TTCorePreprocessorMacros.h\"\r\n\r\n#import \"TTTableView+TouchesMovedAddition.h\"\r\n\r\n@implementation TTTableView (TTTableViewDataSourceNIBCapAddition)\r\n\r\n- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {\r\n [super touchesBegan:touches withEvent:event];\r\n\r\nif ([self.delegate respondsToSelector:@selector(tableView:touchesMoved:withEvent:)]) {\r\n id&lt;TTTableViewDelegate&gt; delegate = (id&lt;TTTableViewDelegate&gt;)self.delegate;\r\n [delegate tableView:self touchesMoved:touches withEvent:event];\r\n }\r\n\r\nif (_highlightedLabel) {\r\n UITouch* touch = [touches anyObject];\r\n _highlightStartPoint = [touch locationInView:self];\r\n }\r\n }\r\n@end<\/pre>\n<p>So if you implement the UITableView protocol in your ViewController which holds, for example, your TTScrollView:<\/p>\n<pre class=\"brush:obj-c\">- (void)tableView:(UITableView*)tableView touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event{\r\n tableView.scrollEnabled = NO;\r\n [_scrollView touchesBegan:touches withEvent:event];\r\n\r\n}\r\n\r\n- (void)tableView:(UITableView*)tableView touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event{\r\n\r\n [_scrollView touchesMoved:touches withEvent:event];\r\n\r\n}\r\n\r\n- (void)tableView:(UITableView*)tableView touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event{\r\n tableView.scrollEnabled = YES;\r\n [_scrollView touchesEnded:touches withEvent:event];<\/pre>\n<p>}<\/p>\n<p>The touch events will be forwarded to the TTScrollView.<\/p>\n<p>Focus on the scrollEnable calls !!!&#8230; \ud83d\ude42<\/p>\n<p>have fun \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a current project I came across the situation that I wanted to implement a cool TTScrollView with a few TTTableViews in it. For some reason in my version of the current Three20 branch the TableView was receiving the &#8220;up and down&#8221; touch events but the parent view (TTSscrollView) didn&#8217;t get any touch events. Googeling &hellip; <a href=\"https:\/\/blog.fh-kaernten.at\/wehr\/2011\/05\/17\/three20-use-tttableview-within-ttscrollview-addition\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Three20 how to use TTTableView within TTScrollView addition<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[13],"tags":[],"class_list":["post-1395","post","type-post","status-publish","format-standard","hentry","category-iphone"],"_links":{"self":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/posts\/1395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/comments?post=1395"}],"version-history":[{"count":0,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/posts\/1395\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/media?parent=1395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/categories?post=1395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/wehr\/wp-json\/wp\/v2\/tags?post=1395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}