Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose scrollsToTop on iOS. #2605

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions apidoc/Titanium/UI/TableView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,18 @@ properties:
since: 2.1.0
platforms: [iphone, ipad]

- name: scrollsToTop
summary: Controls whether the scroll-to-top gesture is effective.
description: |
The scroll-to-top gesture is a tap on the status bar; The default value of this property is true.
This gesture works when you have a single visible table view.
If there are multiple table views visible, you will need to disable (set to false) on the tables you
DON'T want this behaviour on. The remaining table will then respond to scroll-to-top gesture.
type: Boolean
default: true
platforms: [iphone,ipad]
since: 2.2.0

- name: search
summary: Search field to use for the table view.
type: Titanium.UI.SearchBar
Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiUITableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
-(IBAction)hideSearchScreen:(id)sender;
-(UITableView*)tableView;
-(CGFloat)tableRowHeight:(CGFloat)height;
-(void)setScrollsToTop_:(id)value;

#pragma Private
-(void)selectRow:(id)args;
Expand Down
9 changes: 9 additions & 0 deletions iphone/Classes/TiUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,15 @@ -(CGFloat)tableRowHeight:(CGFloat)height
return height < 1 ? tableview.rowHeight : height;
}

//Allows use of scrollsToTop property on a table.
//Useful when you have multiple tables in your view, you can
//set which table will respond to tap on status bar to scroll to top.
//http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html
-(void)setScrollsToTop_:(id)value
{
[[self tableView] setScrollsToTop:[TiUtils boolValue:value]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To have this properly default to true, you'll need [TiUtils boolValue:value def:YES], otherwise doing tv.scrollsToTop=tv.scrollsToTop would set it false if undefined.

}

-(void)setBackgroundColor:(TiColor*)color onTable:(UITableView*)table
{
UIColor* defaultColor = [table style] == UITableViewStylePlain ? [UIColor whiteColor] : [UIColor groupTableViewBackgroundColor];
Expand Down