How to put buttons over UITableView which won't scroll with table in iOS
One solution to this is to extend UIViewController
instead of UITableViewController
. You will need to add your own table view and set everything up. Then you can add your button's to the view controller's view instead of the table view.
Adding buttons to top and bottom of UITableView
I'm not sure exactly where you want your button, but UITableView have a@property(nonatomic, retain) UIView *tableHeaderView
If you want it to be on the top of your tableView and scroll with it, just make the view you want and put it in that property.
Create a button on top of UiTableView
There are a few avenues to take when adding the overlay view:
As a subview of the wrapping
UINavigationController
, which means it won't scroll with the content of the tableAs a section footer of a plain-style
UITableView
that has only 1 sectionAs a subview of the
UITableView
and useUIScrollViewDelegate
'sscrollViewDidScroll:
to continuously update the view's frame as the user scroll's the table (which makes it appear to stay motionless)
floating UIButton with image on a UITableview
You can implement the scrollViewDidScroll
delegate to change your floating button y origin while the user scroll the table, so that the button will float and stay at the same location.
There is a great example in WWDC 2011 session 125 that does exactly what you want.
In general, you need to save the original y origin of the button after you create it, or you can do it in viewDidLoad
, then implement the scrollViewDidScroll
and update the button frame.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGRect tableBounds = self.tableView.bounds;
CGRect floatingButtonFrame = self.floatingButton.frame;
floatingButtonFrame.origin.y = self.originalOrigin + tableBounds.origin.y;
self.floatingButton.frame = floatingButtonFrame;
}
Floating button over UItableview using storyboards
I think best thing you have to do is to create a UIViewController
and add it a UITableView
. Then you can add also the UIButton
you want to the view controller's view. Don't forget to set the view controller to be the delegate and data source for your table view, and to add
to your view controller interface.
iOS floating button over table view
Perhaps adding a toolbar with buttons at the bottom would be a better approach?
Related Topics
Ios App With Arc, Find Who Is Owner of an Object
Uiscrollview Pauses Nstimer Until Scrolling Finishes
How to Test Apple Push Notification Service Without an Iphone
Run App For More Than 10 Minutes in Background
Swiftui | Using Ondrag and Ondrop to Reorder Items Within One Single Lazygrid
How to Hide the Status Bar in a Swift iOS App
Auto Layout Constraints Issue on iOS7 in Uitableviewcell
Layout Issues After Updating to Xcode 8
How to Exclude Notes and Reminders Apps from the Uiactivityviewcontroller
Get the Current Scroll Position of a Swiftui Scrollview
Trying to Handle "Back" Navigation Button Action in Ios
How to Support Universal Links in iOS App and Setup Server For It
How to Locate the Cgrect For a Substring of Text in a Uilabel