Scrolling in NSTableView - objective-c

I'm not asking how to do this, it's more in line of "What would you call this?".
I have an NSTableView with several custom cells. I want the table to scroll row by row, meaning that when I move the scrollbar up I want the top row to disappear and when I move it down I want the bottom row also to disappear - I don't want to see half my cell.
How do you call this type of behavior? And can you share some pointers if you've implemented it in a NSTableView?

I'm not exactly sure what this would be called (maybe something like "constrained scrolling"?), but you can do it using NSView's -adjustScroll: method.
The general approach is that you need to make a subclass of NSTableView (if you don't already have one), and override this method to return a NSRect that has its origin.y value constrained to a multiple of your row height.
You probably also want to use NSScrollView's -setVerticalLineScroll: to set the proper amount to scroll when the user clicks the scroll arrows in the vertical scroll bar. You can get the scrollView by calling -enclosingScrollView on your tableView.

Related

Add Gesture Reconizer Outside UItableView Inside ContentOffSetView

I have added content offset to my UITableView.
For better positioning of my Table and now, I would like to dismiss my UITableView When User taps on the Content Offset Part of My table view.
How can i add this?
Strictly i dont want to add anymore views above the table in my screen.
Have done like Reference to the answer
https://stackoverflow.com/a/39062209/5215474
Without seeing exact code, I would do the following:
Add a UIGestureRecognizer to UITableView
Use a combination of scroll position and the point touched in screenspace to determine if a touch happened where you want.

Getting frame/origin of UIButtons that are outside of visible view in a UIScrollView

How do I go about getting the correct frame (and more importantly, origin) of a UIButton that is outside of the current visible area of a UIScrollView? It seems like when they are not visible, I get erroneous values (i.e. I layout a subview using the frame values I receive, and when I scroll down to it, it is in the wrong place.) Any ideas?
Once again, I've answered my own question. If you have outlets and/or references to your buttons, you'll want to re-reference your button/label/custom view frames in the scrollViewDidScroll method. In my case, I was trying to line up a custom view frame with a button frame, so the implementation looks like this:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
// Enumerate through each object you're looking to reposition and compare them:
if(!(CGRectEqualToRect(bsv.frame, btn.frame))) bsv.frame = btn.frame;
I hope this will help someone out there.

Custom Table in UIViewController Objective-C

I want to create table view inside of UIViewController like a below picture (I mean the second screen)
what is the best solution? "creating UIViewController then tableView and inside of tableView having custom cell"?
would you please give me some hint?
Thanks in advance!
So basically you want the tableview to not fill up the entire space. Yes, you can surely do UIViewController, let it implement UITableViewDelegate and UITableViewDataSource protocols, throw in a tableview and hook up the protocols, and use custom cells.
If you only want the tableview to not fill up the space horizontally (but it can still scroll all the way until it reaches your navbar), then you can just create a UITableViewController, and set up your cell background in the way you want. More specifically, you create 640px (or 320px) wide background images still, but only the central 600px, say, is filled in. The 20px to the right and left are transparent. (You need png to do this, of course) If you apply this background to your cells and apply another background to your self.view, then you can actually see your view background under the 20px on the two sides.
Note that if you choose the second approach, the cells are still full width; it's just that you are visually making them look like narrower. That's perfectly ok, but you need to customize your highlight background, too.
Looking at your picture, it seems you need to create UINavigation Controller as your parent view controller and add UITabBarViewController as its rootview. then in your second tab when your click on the cell inside the table, you pushview to another view which displays your picture
create a tab bar controller project. Every tabbar item will be a navigation controller.
Tat way u can manage both the navigation and tabs.

Force redraw as resizing NSTableColumn in NSTableView?

I've implemented - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row in my NSTableView's delegate to resize the height of my table's rows as the width of the leftmost column changes. The problem is that only that column redraws during the resizing (and any column that slide into view during the resize).
This results in the funky visual below after resizing. What I'd like is a way to tell the table view to completely redraw while the user is resizing a column. Right now the most I've been able to do is call setNeedsDisplay after that column finishes resizing.
Check out the NSTableView method noteHeightOfRowsWithIndexesChanged:. You'll need to make an NSIndexSet of the rows whose heights have changed.
update:
In order to have a safe place to call this, you can subclass NSTableColumn to override the setWidth: method. You can then post a custom notification that your table delegate can observe, or you can override the table view also and have the column tell the table to tell its delegate directly.
It may not be the only way, but giving the table view a Core Animation layer fixed it. It's not 100% smooth, but the average user would probably never notice.

Position of UITableViewCell

I'm using a tableview to display a list of rows and when selected, I want additional controls to appear right below the cell, probably in another view which I will control.
So far, I've managed to get a reference to the selected cell by running through the visiblecells array in the tableview but the frame property always returns a y-coordinate of 0 no matter what scroll position the table is in.
How do I get the position of the cell relative to the window?
I think the best way to deal with table views is in their own terms. That is, if you want to position something new inside the table, put it in a cell. It sounds like you want to subclass UITableViewCell to make your controls, and go through the whole tableView beginUpdates - insertCells - endUpdates process to animate their appearance.