iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – pop视图定位的问题大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在iPad中纵向切换到横向视图(& Vice Versa)时,我的弹出视图的位置会出现乱码.这是我如何计算我的popover视图的框架:

aRect = self.myElement.frame;
aRect.origin.x += aRect.size.width;

[aPopOver presentPopoverFromRect:aRect inView:self.myElement.superview permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];

请告诉我这里有什么问题?

解决方法

好的,我注意到你的代码有些奇怪.

你是否有任何理由将宽度的大小添加到aRect的x位置的原点?
aRect.origin.x = aRect.size.width;

我假设你想要这个是右上角….

您可以取消注释.m文件中的代码并使其如下所示:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     Return YES; // for supported orientations
    //otherwise return (interfaceOrientation == UIInterfaceOrientationLandscape); if you want only landscape mode.
}

或者如果你想布局子视图我会在你的情况下做什么是使用didRotateFromIntferfaceOrientation:像这样:

(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    [self layoutSubviews];
}

还有layoutSubviews

- (void)layoutSubviews
{
    NSLog(@"layoutSubviews called");

    ...recalc rects etc based on the new self.view.bounds...
}

它的工作原理如此.

PK

大佬总结

以上是大佬教程为你收集整理的iphone – pop视图定位的问题全部内容,希望文章能够帮你解决iphone – pop视图定位的问题所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: