tags:

views:

1433

answers:

3

Hi,

I'm quite confused with the whole animation stuff in iPhone SDK. I tried to study throught the SDK documentation, this website or tried googling it out without success. I'm unable to get my scenario work.

  • I have single XIB file, with tab bar and a 4 tabs.
  • In a special event i want to switch from one page to another "in code", so I call eg: [tabController selectedIndex: 0].
  • I need this transition to be animated. Is there a way?
  • If user switches tabs manually, no animated transitions are needed

Also I have one subquestion:

  • In one of the tabs I have a UITableView with set of items. When user clicks any of these items, another set of items are beign shown (sort of hierarchy browser)
  • I tried to animate this transition using -deleteRowsAtIndexPaths:withRowAnimation: and -insertRowsAtIndexPaths:withRowAnimation:, but without luck.
  • Desired transition is shifting the old items set to the left side and the new items from the right side.

This is first time of my iPhone development, when I got lost even with all the forums and documentation. :)

Thanks in advance to anyone trying to help me!

+1  A: 

First Question: No, you can't animate tab switching. Please read Apple's Human Interface Guidelines on this. Tabs are meant to switch instantly. An animated transition would break the "tab" paradigm.

Second Question: When you tap on a row, the user does not expect other rows to disappear and new ones to appear. Instead, this sounds like a case for a UINavigationController. Please refer to Apple's sample code, specifically the UICatalog for sample code on how to implement this.

August
A: 

Ad Second question: Well, maybe you misunderstood me. I dont want to make rows "disappear" or "appear". I have hierarchy browser with 1..n levels (file-browser like), where "n" can be like ten or twenty levels. What i learned about navigation controller is, that it can switch only from one view to another. But i have only one instance of tableview controller and it works like a charm. I dont want to create single view instance for every level of hierarchy. It will be quite an overhead! So there is no other way to accomplish transition effect without having more "dummy" (At least two) views?

+2  A: 

Hi,

As for your first question: Yes you can. Try this link for some answer: transition on tab bar sample code.

In short words: you should add a delegate object to handle the tab bar switching by setting the tabBarController.deleget = self.
Yet, what this forum post won't tell you is that you need to "import" some framework to do it.
First - right-click on the framework folder on the left hand list in xcode and add an existing framework named: "QuartzCore.framework".
Than - add these lines to your tab bar holder (on .h file):
#import < QuartzCore/CAAnimation.h>
#import < QuartzCore/CAMediaTimingFunction.h>

As for your second question, try to replace the datasource (array or what ever) or create login function on the cell to replace its content.

Enjoy!

yn2