I'm trying to modify the appearance of a custom NSTableRowView used in my NSOutlineView when the row expands/collapses. My NSOutlineViewDelegate includes:
- (NSTableRowView *)outlineView:(NSOutlineView *)outlineView rowViewForItem:(id)item
{
...
return rowView;
}
- (void)itemDidExpand:(NSNotification *)notification
{
NSDictionary *userInfo = [notification userInfo];
id item = [userInfo objectForKey:#"NSObject"];
NSOutlineView *outlineView = [notification object];
[outlineView reloadItem:item];
}
This unfortunately doesn't reload the custom row view.
Reloading data for the entire NSOutlineView works:
- (void)itemDidExpand:(NSNotification *)notification
{
[outlineView reloadData];
}
But with large amounts of data this can be time consuming, and often leads to a spinning beach ball.
Is it possible to reload the custom row view for just a single top-level item?
Try the following method:
-(void)outlineView:(NSOutlineView *)outlineView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row {
aColor = [NSColor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0];
[view setBackgroundColor:aColor];
}
You can advance this further to get the row object, and then determine which color you want for a particular row.
-Edit-
If you wish to alter the parent cell view to show that it has been expanded you have implemented the wrong method for the NSOutlineview. Implement the method like the following:
-(void)outlineViewItemWillExpand:(NSNotification *)notification {
id theObject = [[notification userInfo] objectForKey:#"NSObject"];
NSInteger row = [theOutlineView rowForItem:theObject];
NSTableRowView *theRowView = [theOutlineView rowViewAtRow:row makeIfNecessary:NO];
int r = 110;
int g = 110;
int b = 110;
NSColor *aColor = [NSColor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0];
[theRowView setBackgroundColor:aColor];
}
Try this in your rowViewForItem method.
It reloads and redisplays the data for item.
- (void)reloadItem:(id)item;
Related
I am trying to find a way to programmatically resize NSSplitViewItems.
Say the NSWindow frame size is 500x500px.
masterViewItem has a width of 100px, while subViewItem has a width of 400px.
When FOO, I want masterViewItem to collapse to 0px (towards the left),
while subViewItem expands to fill the entire window (500px).
When BAR, I want masterViewItem to expand back to 100px, while subViewItem collapses back to the original 400px.
- (IBAction) onTapOnSomeButton:(NSButton *)sender {
NSWindow *window = [[NSApplication sharedApplication] mainWindow];
NSSplitViewController *splitViewController = (NSSplitViewController *)[window contentViewController];
NSSplitViewItem *masterViewItem =[splitViewController.splitViewItems firstObject];
NSSplitViewItem *subViewItem = [splitViewController.splitViewItems lastObject];
if (FOO) {
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
// Expand subViewItem
} completionHandler:^{
}];
} else if (BAR) {
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
// Expand masterViewItem while shrinking subViewItem
} completionHandler:^{
}];
}
}
I am able to animate each item so that it seems to collapse/expand,
i.e.
subViewItem.viewController.view.animator.frame = CGRectMake(0, 0, window.frame.size.width, subViewItem.viewController.view.frame.size.height);
but the divider will not move, making the two items just move individually, and does not look like the entire screen is collapsing/expanding.
How would I implement this? Thanks in advance.
UPDATE
So I have done a bit more research, and found this:
How to animate the NSSplitView while resizing?
So I made code like this:
- (IBAction) onTapOnSomeButton:(NSButton *)sender {
NSWindow *window = [[NSApplication sharedApplication] mainWindow];
NSSplitViewController *splitViewController = (NSSplitViewController *)[window contentViewController];
NSSplitViewItem *masterViewItem =[splitViewController.splitViewItems firstObject];
NSSplitViewItem *subViewItem = [splitViewController.splitViewItems lastObject];
if (FOO) {
NSMutableDictionary *collapseMainAnimationDict = [NSMutableDictionary dictionaryWithCapacity:2];
[collapseMainAnimationDict setObject: subView forKey:NSViewAnimationTargetKey];
NSRect newRightSubViewFrame = subView.frame;
newRightSubViewFrame.size.width = splitViewController.splitView.frame.size.width;
[collapseMainAnimationDict setObject:[NSValue valueWithRect:newRightSubViewFrame] forKey:NSViewAnimationEndFrameKey];
NSMutableDictionary *collapseInspectorAnimationDict = [NSMutableDictionary dictionaryWithCapacity:2];
[collapseInspectorAnimationDict setObject: masterView forKey:NSViewAnimationTargetKey];
NSRect newLeftSubViewFrame = masterView.frame;
newLeftSubViewFrame.size.width = 0.0f;
newLeftSubViewFrame.origin.x = splitViewController.splitView.frame.size.width;
[collapseInspectorAnimationDict setObject:[NSValue valueWithRect:newLeftSubViewFrame] forKey:NSViewAnimationEndFrameKey];
NSViewAnimation *collapseAnimation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects: collapseMainAnimationDict, collapseInspectorAnimationDict, nil]];
[collapseAnimation setDuration:0.3f];
[collapseAnimation startAnimation];
[splitViewController.splitView adjustSubviews];
[splitViewController.splitView setNeedsDisplay: YES];
} else if (BAR) {
// Not yet implemented
}
}
But to no effect. Any suggestions?
You have to resize the panes using [NSSplitView setPosition:ofDividerAtIndex:].
I have no idea what NSSplitViewController is, but presumably you can get access to the NSSplitView via its view property, or some such.
Rather than looking at it as a resize, it sounds like you're simply trying to collapse/uncollapse the master view item. You can just use NSSplitViewItem's collapsed property with its animator proxy to trigger the collapse:
if (FOO) {
// Expand subViewItem (collapse the master view item)
masterViewItem.animator.collapsed = YES;
And uncollapse:
} else if (BAR) {
// Expand masterViewItem while shrinking subViewItem
masterViewItem.animator.collapsed = NO;
}
}
With 10.11, there's API to designate your master view item as a "sidebar", which has additional collapse/uncollapse behavior for that item (such as overlays).
I am working on a project that has the concept of draggable controls, everything is working fine except that NSView seems to employ a fade in/out animation when calling setHidden:.
I have been able to work around the problem by changing the line session.animatesToStartingPositionsOnCancelOrFail = YES; to NO and implementing the image snapback myself with a custom animated NSWindow subclass. it looks great, but I know there must be an easier way.
I have tried:
using NSAnimationContext grouping with duration of 0 around the setHidden: calls
setting the view animations dictionary using various keys (alpha, hidden, isHidden) on the control and superview
overriding animationForKey: for both the control and its superview
I am not using CALayers and have even tried explicitly setting wantsLayer: to NO.
Does anybody know how to either disable this animation, or have a simpler solution then my animated NSWindow?
here is my stripped down altered code with the bare minimum to see what I'm talking about.
#implementation NSControl (DragControl)
- (NSDraggingSession*)beginDraggingSessionWithDraggingCell:(NSActionCell <NSDraggingSource> *)cell event:(NSEvent*) theEvent
{
NSImage* image = [self imageForCell:cell];
NSDraggingItem* di = [[NSDraggingItem alloc] initWithPasteboardWriter:image];
NSRect dragFrame = [self frameForCell:cell];
dragFrame.size = image.size;
[di setDraggingFrame:dragFrame contents:image];
NSArray* items = [NSArray arrayWithObject:di];
[self setHidden:YES];
return [self beginDraggingSessionWithItems:items event:theEvent source:cell];
}
- (NSRect)frameForCell:(NSCell*)cell
{
// override in multi-cell cubclasses!
return self.bounds;
}
- (NSImage*)imageForCell:(NSCell*)cell
{
return [self imageForCell:cell highlighted:[cell isHighlighted]];
}
- (NSImage*)imageForCell:(NSCell*)cell highlighted:(BOOL) highlight
{
// override in multicell cubclasses to just get an image of the dragged cell.
// for any single cell control we can just make sure that cell is the controls cell
if (cell == self.cell || cell == nil) { // nil signifies entire control
// basically a bitmap of the control
// NOTE: the cell is irrelevant when dealing with a single cell control
BOOL isHighlighted = [cell isHighlighted];
[cell setHighlighted:highlight];
NSRect cellFrame = [self frameForCell:cell];
// We COULD just draw the cell, to an NSImage, but button cells draw their content
// in a special way that would complicate that implementation (ex text alignment).
// subclasses that have multiple cells may wish to override this to only draw the cell
NSBitmapImageRep* rep = [self bitmapImageRepForCachingDisplayInRect:cellFrame];
NSImage* image = [[NSImage alloc] initWithSize:rep.size];
[self cacheDisplayInRect:cellFrame toBitmapImageRep:rep];
[image addRepresentation:rep];
// reset the original cell state
[cell setHighlighted:isHighlighted];
return image;
}
// cell doesnt belong to this control!
return nil;
}
#pragma mark NSDraggingDestination
- (void)draggingEnded:(id < NSDraggingInfo >)sender
{
[self setHidden:NO];
}
#end
#implementation NSActionCell (DragCell)
- (void)setControlView:(NSView *)view
{
// this is a bit of a hack, but the easiest way to make the control dragging work.
// force the control to accept image drags.
// the control will forward us the drag destination events via our DragControl category
[view registerForDraggedTypes:[NSImage imagePasteboardTypes]];
[super setControlView:view];
}
- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp
{
BOOL result = NO;
NSPoint currentPoint = theEvent.locationInWindow;
BOOL done = NO;
BOOL trackContinously = [self startTrackingAt:currentPoint inView:controlView];
BOOL mouseIsUp = NO;
NSEvent *event = nil;
while (!done)
{
NSPoint lastPoint = currentPoint;
event = [NSApp nextEventMatchingMask:(NSLeftMouseUpMask|NSLeftMouseDraggedMask)
untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode
dequeue:YES];
if (event)
{
currentPoint = event.locationInWindow;
// Send continueTracking.../stopTracking...
if (trackContinously)
{
if (![self continueTracking:lastPoint
at:currentPoint
inView:controlView])
{
done = YES;
[self stopTracking:lastPoint
at:currentPoint
inView:controlView
mouseIsUp:mouseIsUp];
}
if (self.isContinuous)
{
[NSApp sendAction:self.action
to:self.target
from:controlView];
}
}
mouseIsUp = (event.type == NSLeftMouseUp);
done = done || mouseIsUp;
if (untilMouseUp)
{
result = mouseIsUp;
} else {
// Check if the mouse left our cell rect
result = NSPointInRect([controlView
convertPoint:currentPoint
fromView:nil], cellFrame);
if (!result)
done = YES;
}
if (done && result && ![self isContinuous])
[NSApp sendAction:self.action
to:self.target
from:controlView];
else {
done = YES;
result = YES;
// this bit-o-magic executes on either a drag event or immidiately following timer expiration
// this initiates the control drag event using NSDragging protocols
NSControl* cv = (NSControl*)self.controlView;
NSDraggingSession* session = [cv beginDraggingSessionWithDraggingCell:self
event:theEvent];
// Note that you will get an ugly flash effect when the image returns if this is set to yes
// you can work around it by setting NO and faking the release by animating an NSWindowSubclass with the image as the content
// create the window in the drag ended method for NSDragOperationNone
// there is [probably a better and easier way around this behavior by playing with view animation properties.
session.animatesToStartingPositionsOnCancelOrFail = YES;
}
}
}
return result;
}
#pragma mark - NSDraggingSource Methods
- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context
{
switch(context) {
case NSDraggingContextOutsideApplication:
return NSDragOperationNone;
break;
case NSDraggingContextWithinApplication:
default:
return NSDragOperationPrivate;
break;
}
}
- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation
{
// now tell the control view the drag ended so it can do any cleanup it needs
// this is somewhat hackish
[self.controlView draggingEnded:nil];
}
#end
There must be a layer enabled somewhere in your view hierarchy, otherwise there wouldn't be a fade animation. Here is my way of disabling such animations:
#interface NoAnimationImageView : NSImageView
#end
#implementation NoAnimationImageView
+ (id)defaultAnimationForKey: (NSString *)key
{
return nil;
}
#end
The solution you already tried by setting the view animations dictionary should work. But not for the keys you mention but for the following. Use it somewhere before the animation is triggered the first time. If you have to do it on the window or view or both, I don't know.
NSMutableDictionary *animations = [NSMutableDictionary dictionaryWithDictionary:[[theViewOrTheWindow animator] animations];
[animations setObject:[NSNull null] forKey: NSAnimationTriggerOrderIn];
[animations setObject:[NSNull null] forKey: NSAnimationTriggerOrderOut];
[[theViewOrTheWindow animator] setAnimations:animations];
Or also just remove the keys if they are there (might not be the case as they are implicit / default):
NSMutableDictionary *animations = [NSMutableDictionary dictionaryWithDictionary:[[theViewOrTheWindow animator] animations];
[animations removeObjectForKey:NSAnimationTriggerOrderIn];
[animations removeObjectForKey:NSAnimationTriggerOrderOut];
[[theViewOrTheWindow animator] setAnimations:animations];
Ok. I figured out that the animation I'm seeing is not the control, the superview, nor the control's window. It appears that animatesToStartingPositionsOnCancelOrFail causes NSDraggingSession to create a window (observed with QuartzDebug) and put the drag image in it and it is this window that animates back to the origin and fades out before the setHidden: call is executed (i.e. before the drag operation is concluded).
Unfortunately, the window that it creates is not an NSWindow so creating a category on NSWindow doesn't disable the fade animation.
Secondly, there is no public way that I know of to get a handle on the window, so I can't attempt directly manipulating the window instance.
It looks like maybe my workaround is the best way to do this, after all its not far from what AppKit does for you anyway.
If anybody knows how to get a handle on this window, or what class it is I would be interested to know.
I my outline view, i am adding Custom cell, To drawing custom cell, i am referring example code , present in the Cocoa documentation
http://www.martinkahr.com/2007/05/04/nscell-image-and-text-sample/
I want to change the disclosure image of the cell with my custom image, i have tried following things
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
if([item isKindOfClass:[NSValue class]])
{
MyData *pDt = (MyData *)[item pointerValue];
if(pDt->isGroupElement())
{
[cell setImage:pGroupImage];
}
}
}
but that too not working, Is there any other way to change the disclosure image,
also how can i find out in willDisplayCell whether Item is expand or collapse, so i can set the image accordingly,
Is this only the place to change the disclosure image ?
After researching this issue myself, and trying some of the answers here, I have found that the other approaches mentioned will work, but will require that you perform a lot more manual intervention in order to avoid screen artifacts and other strange behavior.
The simplest solution I found is the following, which should work in most cases.
This solution has the added benefit of the system automatically handling a great many other cases, such as column movement, etc, without your involvement.
- (void)outlineView:(NSOutlineView *)outlineView willDisplayOutlineCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn
item:(id)item
{
[cell setImage:[NSImage imageNamed: #"Navigation right 16x16 vWhite_tx"]];
[cell setAlternateImage:[NSImage imageNamed: #"Navigation down 16x16 vWhite_tx"]];
}
In your case, you would wrap this up with your class detection logic, and set the cell images appropriately for your cases.
A nice way to change the disclosure image is to use a view based outline view:
In your ViewController with NSOutlineViewDelegate:
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
CustomNSTableCellView *cell = [outlineView makeViewWithIdentifier:tableColumn.identifier owner:self];
cell.item = item;
return cell;
}
You have to subclass your NSOutlineView and overide the method:
- (id)makeViewWithIdentifier:(NSString *)identifier owner:(id)owner
{
id view = [super makeViewWithIdentifier:identifier owner:owner];
if ([identifier isEqualToString:NSOutlineViewDisclosureButtonKey])
{
// Do your customization
// return disclosure button view
[view setImage:[NSImage imageNamed:#"Disclosure_Categories_Plus"]];
[view setAlternateImage:[NSImage imageNamed:#"Disclosure_Categories_Minus"]];
[view setBordered:NO];
[view setTitle:#""];
return view;
}
return view;
}
//Frame of the disclosure view
- (NSRect)frameOfOutlineCellAtRow:(NSInteger)row
{
NSRect frame = NSMakeRect(4, (row * 22), 19, 19);
return frame;
}
For who looks for Swift2 Solution. Subclass NSRow of your outlineview and override didAddSubview method as below.
override func didAddSubview(subview: NSView) {
super.didAddSubview(subview)
if let sv = subview as? NSButton {
sv.image = NSImage(named:"IconNameForCollapsedState")
sv.alternateImage = NSImage(named:"IconNameForExpandedState")
}
}
You've got the basic idea but what you will need to do is draw the image yourself. Here's the code I use:
- (void)outlineView:(NSOutlineView *)outlineView willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item {
NSString *theImageName;
NSInteger theCellValue = [cell integerValue];
if (theCellValue==1) {
theImageName = #"PMOutlineCellOn";
} else if (theCellValue==0) {
theImageName = #"PMOutlineCellOff";
} else {
theImageName = #"PMOutlineCellMixed";
}
NSImage *theImage = [NSImage imageNamed: theImageName];
NSRect theFrame = [outlineView frameOfOutlineCellAtRow:[outlineView rowForItem: item]];
theFrame.origin.y = theFrame.origin.y +17;
// adjust theFrame here to position your image
[theImage compositeToPoint: theFrame.origin operation:NSCompositeSourceOver];
[cell setImagePosition: NSNoImage];
}
You will need 3 different images as you can see, one for the ON state, one for the OFF state and also one for the MIXED state which should be halfway between the two. The mixed state makes sure you still get the opening and closing animation.
This is what i have tried and working so far,
/* because we are showing our own disclose and expand button */
- (NSRect)frameOfOutlineCellAtRow:(NSInteger)row {
return NSZeroRect;
}
- (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row {
NSRect superFrame = [super frameOfCellAtColumn:column row:row];
if ((column == 0) && ([self isGroupItem:[self itemAtRow:row]])) {
return NSMakeRect(0, superFrame.origin.y, [self bounds].size.width, superFrame.size.height);
}
return superFrame;
}
I have subclassed NSOutlineView class and override these methods,
[self isGroupItem] is to check whether its group or not.
but got one problem, now looks like mousehandling i need to do :( , on double clicking group row is not toggling
In my NSOutlineview i am using custom cell which is subclassed from NSTextFieldCell,
I need to draw different color for group row and for normal row, when its selected,
To do so, i have done following ,
-(id)_highlightColorForCell:(NSCell *)cell
{
return [NSColor colorWithCalibratedWhite:0.5f alpha:0.7f];
}
Yep i know its private API, but i couldn't found any other way,
this is working very well for Normal Row, but no effect on Group Row, Is there any way to change the group color,
Kind Regards
Rohan
You can actually do this without relying on private API's, at least if your willing to require Mac OS X 10.4 or better.
Put the following in your cell subclass:
- (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
// Returning nil circumvents the standard row highlighting.
return nil;
}
And then subclass the NSOutlineView and re-implement the method, - (void)highlightSelectionInClipRect:(NSRect)clipRect;
Here's an example that draws one color for non-group rows and another for group rows
- (void)highlightSelectionInClipRect:(NSRect)clipRect
{
NSIndexSet *selectedRowIndexes = [self selectedRowIndexes];
NSRange visibleRows = [self rowsInRect:clipRect];
NSUInteger selectedRow = [selectedRowIndexes firstIndex];
while (selectedRow != NSNotFound)
{
if (selectedRow == -1 || !NSLocationInRange(selectedRow, visibleRows))
{
selectedRow = [selectedRowIndexes indexGreaterThanIndex:selectedRow];
continue;
}
// determine if this is a group row or not
id delegate = [self delegate];
BOOL isGroupRow = NO;
if ([delegate respondsToSelector:#selector(outlineView:isGroupItem:)])
{
id item = [self itemAtRow:selectedRow];
isGroupRow = [delegate outlineView:self isGroupItem:item];
}
if (isGroupRow)
{
[[NSColor alternateSelectedControlColor] set];
} else {
[[NSColor secondarySelectedControlColor] set];
}
NSRectFill([self rectOfRow:selectedRow]);
selectedRow = [selectedRowIndexes indexGreaterThanIndex:selectedRow];
}
}
I have an UITableView with sections in my iPhone application where it looks as something similar to viewing a contact details in standard contacts app. In one of the sections I have a UISegmentedControl set as a header of the section and the items in that section depend on what segment is selected in the segmented control. What I wanted to do is to have animations shifting the rows of one tab out of the view to one side and shifting the rows of another tab in from the other side. I have managed to achieve this by inserting/deleting the respective rows with default UITableView's animations for that but it looks a bit weird when the number of rows in one tab is different from the other one. Also the code for that is quite nasty.
Here's the code I have (simplified a bit):
[self.tableView beginUpdates];
UITableViewRowAnimation delAnim = UITableViewRowAnimationRight;
UITableViewRowAnimation insAnim = UITableViewRowAnimationLeft;
NSUInteger numdel = [self.list count];
NSUInteger numins = [newlist count];
NSMutableArray* indices = [NSMutableArray arrayWithCapacity: numdel];
for (NSUInteger i = 0; i < numins; i++)
{
[indices addObject: [NSIndexPath indexPathForRow: i inSection: SECT]];
}
[self.tableView insertRowsAtIndexPaths: indices withRowAnimation: insAnim];
[indices removeAllObjects];
for (NSUInteger i = 0; i < numdel; i++)
{
[indices addObject: [NSIndexPath indexPathForRow: i inSection: SECT]];
}
[self.tableView deleteRowsAtIndexPaths: indices withRowAnimation: delAnim];
self.list = newlist;
[self.tableView endUpdates];
I'm fairly new to Objective C and Cocoa, so any advices are very welcome.
You could try using a separate table view which you animate in directly. The snippet here is just typed off-the-cuff, so might need some work, but it should give you some pointers at least:
- (void) switchToNewTableFromRight
{
UITableView * newTableView = [[UITableView alloc] initWithFrame: self.tableView.frame style: self.tableView.style];
// put it off to the right of the existing table
CGRect frame = newTableView.frame;
frame.origin.x += frame.size.width;
newTableView.frame = frame;
// set data for new table
// you should ensure you're setup to supply data for the new table here, btw
newTableView.delegate = self;
newTableView.dataSource = self;
[newTableView reloadData];
// add to parent of current table view at this (offscreen) location
[self.tableView.superview addSubview: newTableView];
// now we animate
[UIView beginAnimations: #"TableFromRight" context: newTableView];
// set the function it should call when the animation completes
[UIView setAnimationDelegate: self];
[UIView setAnimationDidStopSelector: #selector(animation:finished:context:)];
// set new table's frame to current table's frame
newTableView.frame = self.tableView.frame;
// set current table's frame to be offscreen to the left
frame = self.tableView.frame;
frame.origin.x -= frame.size.width;
self.tableView.frame = frame;
// commit the animations to start them going
[UIView commitAnimations];
}
- (void) animation: (NSString *) animationID finished: (BOOL) finished context: (void *) context
{
// could be a good idea to check that finished == YES here
UITableView * newTableView = (UITableView *) context;
self.tableView = newTableView;
// newTableView has been inited but not autoreleased, etc.
// now the controller (self) owns it, so release that first reference
[newTableView release];
}
The idea here is that you setup the new table (making it the same size as the existing one), place it offscreen to the right of the existing table, and then animate the movement of both tables left by their width. This way the existing table will shift offscreen while the new one will shift onscreen. When the animation completes it will call the supplied method, giving you the opportunity to make the new table view the official table view.
Another option would be to use a flip transition, which might go something like this:
// setup new table
UITableView * newTableView = [[UITableView alloc] initWithFrame: self.tableView.frame style: self.tableView.style];
newTableView.delegate = self;
newTableView.dataSource = self;
[newTableView reloadData];
[UIView beginAnimations: nil context: NULL];
[UIView setAnimationDuration: 1.0];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView: self.tableView.superview cache: YES];
// generally here you'd remove the old view and add the new view
// I'm *assuming* that UITableViewController's -setTableView: will do the same thing
self.tableView = newTableView;
[UIView commitAnimations];
Hopefully one of those will have the desired effect.