Optimize your Twitter feed.
- Authenticate to access a user's Twitter feed
- Display the feed as Twitter does
- Allow the user to swipe left or right on any tweet
Left = indicate that you dislike the tweet
| - (void)scrollViewDidScroll:(UIScrollView *)scrollView { | |
| if (scrollView.contentOffset.x > 0) { | |
| scrollView.contentOffset = CGPointZero; | |
| } | |
| } |
| 2015-01-26 22:19:55.120 SwipeableTableViewCell[21735:2347995] setFrame | |
| frame={{0, 0}, {320, 44}} | |
| self.bounds={{0, 0}, {320, 44}} | |
| self.frame={{0, 0}, {320, 44}} | |
| self.contentView.bounds={{0, 0}, {0, 0}} | |
| self.scrollView.bounds={{0, 0}, {0, 0}} | |
| self.scrollView.frame={{0, 0}, {0, 0}} | |
| self.scrollView.contentOffset={0, 0} | |
| 2015-01-26 22:19:55.121 SwipeableTableViewCell[21735:2347995] setFrame |
| - (void)layoutSubviews { | |
| [super layoutSubviews]; | |
| // This is necessary to ensure that the content size scales with the view. | |
| self.scrollView.contentSize = self.contentView.bounds.size; | |
| self.scrollView.contentOffset = CGPointZero; | |
| } |
| - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset { | |
| if (scrollView.contentOffset.x < -scrollView.contentInset.left) { | |
| targetContentOffset->x = -scrollView.contentInset.left; | |
| } else { | |
| *targetContentOffset = CGPointZero; | |
| } | |
| } |
| // Set up the container for the buttons that appear when swiping. | |
| UIView *buttonsView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 160, self.bounds.size.height)]; | |
| buttonsView.autoresizingMask = UIViewAutoresizingFlexibleHeight; | |
| self.buttonsView = buttonsView; | |
| [self.scrollView insertSubview:buttonsView atIndex:0]; | |
| // Create two action buttons and put them in the container. | |
| UIButton *yesButton = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| yesButton.autoresizingMask = UIViewAutoresizingFlexibleHeight; | |
| yesButton.backgroundColor = [UIColor greenColor]; |
| // Set up main content area. | |
| UIView *contentView = [[UIView alloc] initWithFrame:scrollView.bounds]; | |
| contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | |
| contentView.backgroundColor = [UIColor whiteColor]; | |
| [scrollView addSubview:contentView]; | |
| self.scrollViewContentView = contentView; | |
| // Put a label in the scroll view content area. | |
| UILabel *label = [[UILabel alloc] initWithFrame:CGRectInset(contentView.bounds, 10, 0)]; | |
| label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
| // Create the scroll view which enables the horizontal swiping. | |
| UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.bounds]; | |
| scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | |
| scrollView.contentSize = self.bounds.size; | |
| scrollView.contentInset = UIEdgeInsetsMake(0, 160, 0, 0); | |
| scrollView.delegate = self; | |
| scrollView.scrollsToTop = NO; | |
| scrollView.showsHorizontalScrollIndicator = NO; | |
| scrollView.showsVerticalScrollIndicator = NO; | |
| [self.contentView addSubview:scrollView]; |
| @interface SwipeableTableViewCell : UITableViewCell <UIScrollViewDelegate> |
| def add_cors_headers(response): | |
| response.headers['Access-Control-Allow-Origin'] = '*' | |
| if request.method == 'OPTIONS': | |
| response.headers['Access-Control-Allow-Methods'] = 'DELETE, GET, POST, PUT' | |
| headers = request.headers.get('Access-Control-Request-Headers') | |
| if headers: | |
| response.headers['Access-Control-Allow-Headers'] = headers | |
| return response | |
| app.after_request(add_cors_headers) |