当navigationController里面的tableViewController进行方向更改时,无法获取reloadData来更新表

时间:2011-05-02 21:16:24

标签: iphone objective-c uitableview orientation

我有一个tableViewController,它最初是屏幕上的主视图控制器。在这种情况下,我使用了willRotateToInterfaceOrientation:toInterfaceOrientation:duration方法来调用reloadData以使我的表重新加载其内容。这有点像预期的那样,在方向改变时,表格将重新加载其内容。

稍后,我需要将tableViewController放入navigationController。完成此操作后,仍会被调用的willRotateToInterfaceOrientation:toInterfaceOrientation:duration方法无法正确刷新表内容。

我的猜测是,通过将tableViewController放入navigationController,这已经影响了发送旋转事件的顺序,并且当调用reloadData方法时,它在tableView的生命周期中为时过早,并且在旋转之前发生了更改。我已经确保使用一些日志语句调用willRotateToInterfaceOrientation:toInterfaceOrientation:duration方法。另外,为了看看会发生什么,我实现了didRotateFromInterfaceOrientation:fromInterfaceOrientation方法,我放置了reloadData语句,这样就可以正确地重新加载表内容。但是,这会在旋转动画之后发生,然后重绘表格,从而产生明显的UI移动。

有没有其他人在此之前看到此行为或知道如何解决此问题?

感谢您的任何建议。

1 个答案:

答案 0 :(得分:2)

您还应该查看其他视图旋转方法。请参阅http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

中的“回复查看轮换事件”

也许这两个中的一个?

- didAnimateFirstHalfOfRotationToInterfaceOrientation:
- willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:
相关问题