当方向改变时以编程方式改变笔尖
我在 init 中像这样加载我的笔尖:
self = [super initWithNibName:@"PageView_iPhone" bundle:nil];
但是如果方向发生变化,如何在运行时(即 init 之后)更改它? initWithNibName
将不起作用。
I load my nibs like this in the init:
self = [super initWithNibName:@"PageView_iPhone" bundle:nil];
But how do I change this during runtime (i.e. after the init) if the orientation changes? initWithNibName
won't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您确实想加载不同的笔尖,您可以使用:
If you really want to load a different nib, you could use:
在初始化期间,我设置视图(以编程方式创建它们),并为视图控制器中的每个视图的中心位置创建额外的 CGPoint 或为框架创建 CGRect。
在 init 中创建视图后,我调用名为layoutViewsForOrientation 的方法来设置初始位置,并传入当前状态栏方向。当方向改变时,我使用以下代码:
可能有一种更简单的方法,但这很适合我的需要。
During init, I setup my views (create them programatically) and create extra CGPoint's for center positions or CGRect's for frames for each view in the view controller.
After the views are created in init, I call method named layoutViewsForOrientation to set the initial position, passing in the current status bar orientation. When the orientation changes, I use this code:
There may be an easier way, but this works well for my needs.