获取“使用两阶段旋转动画” UIImagePickerController 发出警告

发布于 2024-09-02 01:20:50 字数 720 浏览 3 评论 0原文

我编写了简单的代码来测试 UIImagePickerController:

@implementation ProfileEditViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  photoTaker_ = [[UIImagePickerController alloc] init];
  photoTaker_.delegate = self;
  photoTaker_.sourceType = UIImagePickerControllerSourceTypeCamera;
  photoTaker_.showsCameraControls = NO;
}

- (void)viewDidAppear: (BOOL)animated {
  [self presentModalViewController: photoTaker_ animated: NO];
}

@end

并且我收到如下奇怪的警告:

2010-05-20 17:53:13.838 TestProj[2814:307] 使用两阶段旋转动画。要使用更平滑的单阶段动画,此应用程序必须删除两阶段方法实现。 2010-05-20 17:53:13.849 TestProj[2814:307] 当旋转多个视图控制器或视图控制器而不是窗口委托时,不支持使用两阶段旋转动画

知道这是怎么回事吗?预先非常感谢!

I wrote simple code to test UIImagePickerController:

@implementation ProfileEditViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  photoTaker_ = [[UIImagePickerController alloc] init];
  photoTaker_.delegate = self;
  photoTaker_.sourceType = UIImagePickerControllerSourceTypeCamera;
  photoTaker_.showsCameraControls = NO;
}

- (void)viewDidAppear: (BOOL)animated {
  [self presentModalViewController: photoTaker_ animated: NO];
}

@end

And I'm getting strange warnings like the following:

2010-05-20 17:53:13.838 TestProj[2814:307] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
2010-05-20 17:53:13.849 TestProj[2814:307] Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate

Got any idea what this is about? Thanks a lot in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

稳稳的幸福 2024-09-09 01:20:50

如果您在另一个 UIViewController 中呈现 UIImagePickerController,则会出现此消息。因为它不像 UINavigationController 堆栈那样推送,所以在 UIWindow 级别存在混乱。我不知道该警告是否有问题,但要消除该警告,您可以执行以下操作:

// self = a UIViewController  
//  

- (void) showCamera  
{  
    cameraView = [[UIImagePickerController alloc] init];  
    [[[UIApplication sharedApplication] keyWindow] setRootViewController:cameraView];  
    [self presentModalViewController:cameraView animated:NO];  
}   

- (void) removeCamera  
{  
    [[[UIApplication sharedApplication] keyWindow] setRootViewController:self];  
    [self dismissModalViewControllerAnimated:NO];  
    [cameraView release];  
}  

This message will appear if you are presenting the UIImagePickerController within another UIViewController. Because it isn't pushed like a UINavigationController stack, there is confusion at the UIWindow level. I don't know if the warning is a problem, but to eliminate the warning you can do the following:

// self = a UIViewController  
//  

- (void) showCamera  
{  
    cameraView = [[UIImagePickerController alloc] init];  
    [[[UIApplication sharedApplication] keyWindow] setRootViewController:cameraView];  
    [self presentModalViewController:cameraView animated:NO];  
}   

- (void) removeCamera  
{  
    [[[UIApplication sharedApplication] keyWindow] setRootViewController:self];  
    [self dismissModalViewControllerAnimated:NO];  
    [cameraView release];  
}  
美胚控场 2024-09-09 01:20:50

也许您将根 UIViewController 的视图添加为窗口的子视图,而不是将视图控制器分配给窗口的 rootController 属性?

Perhaps you are adding the root UIViewController's view as a subview of the window instead of assigning the view controller to the window's rootController property?

东京女 2024-09-09 01:20:50

一切都回到 UI

这个警告可以针对几个不同的对象实现:选择器、键盘等。

我发现它与 UI 需要两个步骤来完成过渡或其他动画有关。或者,对于 UI 尝试完成一件事并在完成之前被要求执行另一件事的任何情况。 (因此它涵盖了广泛的可能触发因素)

我已经看到警告出现在 4.0 和 4.0 上。 4.2.就我而言,我正在旋转设备并捕获键盘是否仍然处于打开状态(即文本字段仍然是第一响应者)。如果是这样,键盘需要在视图之间保持不动,但这会带来其他视图的复杂性。

因此,我实现了一个 BOOL 跟踪器来跟踪 keybaordIsPresent 是否存在,如果是的话我是 {textfield resignFirstResponder];当检测到方向变化并在包装在动画块中的转换之后将文本字段重置为FristResponder 时。我的 BOOL 跟踪器工作得更好,我仍然使用键盘的 NSNotifications,但是在旋转期间通知有重叠,因为键盘在没有请求的情况下被关闭。在加载时以及 [textfield resignFirstResponder] 时,BOOL 设置为 NO;已实施。 *不是当“-(void)keyboardWillhide 由 NSNotifications 触发时,这给了我两个永远不会冲突的工作触发器。只有当用户触摸文本字段时,BOOL 设置为 YES,该文本字段会自动触发变为FirstResponder。

我通过采取以下方式删除了警告[textfild resignFirstResponder]; 退出

-(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
//if (keyboardIsPresent == YES) {[self.entryTextField resignFirstResponder];}

}
并将其放回代码的顶部:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {

if (keyboardIsPresent == YES) {
    [self.entryTextField resignFirstResponder];
}

//Determine Which Orientation is Present:
if((fromInterfaceOrientation == UIInterfaceOrientationPortrait) || (fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){
    //LANDSCAPE VIEW:
    [self configureLandscapeView];
}else {
    //PORTRAIT VIEW:
    [self configurePortraitView];
}

}


**Even though I had no code inside the -(void)willAnimatFirstHalfOfRotationToInterface:, the warning was still popping up. I think the warning was still popping up because the compiler still has to attempt the method while it is trying to execute the first animation and therefore gets the double animation call or overlap of resources. It doesn't know that there is no executable code with the method until after it runs through it. And by that time it already set aside resource in preparation for handling possible actions within the method.


**To ellimiate the warning I had to remove or nil out the code for the willAnimateFirstHalfOfRotation, so that the compiler does not have to even check to see if there is a possible 2nd animation or action that may need to be executed at the same time.

/*-(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
//if (keyboardIsPresent == YES) {[self.entryTextField resignFirstResponder];}}*/

转换完成后,在原始动画块内,我检查“keyboardIsPresent”在旋转之前是否为“是”,如果是,则再次辞去第一响应者。我使用 setAnimationDuration:0.3 ,结果非常干净且不跳动。

IT ALL FALLS BACK ON THE UI

This warning can be implemented for several different objects: Pickers, keyboard, etc.

I have found that it is related to the UI taking two steps to complete a transition or other animation. Or for any instance where the UI is trying to finish one thing and is being asked to execute another before it has finished. (therefore it covers a wide range of possible triggers)

I have seen the warning appear on 4.0 & 4.2. In my case I was working with rotating the device and catching whether the keyboard was still up-(i.e. text field was still first responder). If so, the keyboard needed to stay up for between the views, but this presented other complications with other views.

Therefore, I implemented a BOOL tracker to keep track if keybaordIsPresent, and if so I was {textfield resignFirstResponder]; when detecting the orientation change and the reset the textfield to becomeFristResponder after the transition that was wrapped in an Animation Block. My BOOL tracker worked better, I still use the NSNotifications for the Keyboard, but there were overlaps of notifications during rotations because the keyboard was being dismissed without requesting such. The BOOL is set to NO on Load, and when the [textfield resignFirstResponder]; is implemented. *not when "-(void)keyboardWillhide is trigger by the NSNotifications, which gives me both working triggers that never conflict. The BOOL is set to YES, only when the user touches textfield which automatically triggers becomeFirstResponder.

I removed the warning by taking the [textfild resignFirstResponder]; out of the

-(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
//if (keyboardIsPresent == YES) {[self.entryTextField resignFirstResponder];}

}
and placing it back at the top of the code for the:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {

if (keyboardIsPresent == YES) {
    [self.entryTextField resignFirstResponder];
}

//Determine Which Orientation is Present:
if((fromInterfaceOrientation == UIInterfaceOrientationPortrait) || (fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){
    //LANDSCAPE VIEW:
    [self configureLandscapeView];
}else {
    //PORTRAIT VIEW:
    [self configurePortraitView];
}

}


**Even though I had no code inside the -(void)willAnimatFirstHalfOfRotationToInterface:, the warning was still popping up. I think the warning was still popping up because the compiler still has to attempt the method while it is trying to execute the first animation and therefore gets the double animation call or overlap of resources. It doesn't know that there is no executable code with the method until after it runs through it. And by that time it already set aside resource in preparation for handling possible actions within the method.


**To ellimiate the warning I had to remove or nil out the code for the willAnimateFirstHalfOfRotation, so that the compiler does not have to even check to see if there is a possible 2nd animation or action that may need to be executed at the same time.

/*-(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
//if (keyboardIsPresent == YES) {[self.entryTextField resignFirstResponder];}}*/

After the transition is completed, within the original animation block I check to see if the "keyboardIsPresent" was YES prior to the rotation, and if so, I resign the First Responder once again. I use setAnimationDuration:0.3which comes out pretty clean and not jumpy.

笑饮青盏花 2024-09-09 01:20:50

好吧,您正在 ProfileEditViewController 的 viewDidAppear 中以模态方式呈现 UIImagePickerController。

想想这个。这意味着当 ProfileEditViewController 视图出现时,UIImagePickerController 出现,稍后你关闭 UIImagePickerController 并返回到 ProfileEditViewController,然后再次调用 viewDidAppear 并出现 UIImagePickerController,稍后你关闭 UIImagePickerController 并返回到 ProfileEditViewController,然后再次调用 viewDidAppear 并....你明白了。

不过,这个警告相当神秘,不确定这是否是它想要告诉你的。我建议在 ProfileEditViewController 的某处创建一个按钮来调用presentModalViewController,并确保您有一种方法来关闭 UIImagePickerController (我从未使用过它,不确定它是否自动有一个)。

Well, you are presenting UIImagePickerController modally inside viewDidAppear of ProfileEditViewController.

Think about this. That means when ProfileEditViewController view appears, the UIImagePickerController appears, say later you dismiss UIImagePickerController and it goes back to ProfileEditViewController, then viewDidAppear is called again and UIImagePickerController appears, say later you dismiss UIImagePickerController and it goes back to ProfileEditViewController, then viewDidAppear is called again and.... you get the idea.

That warning is rather cryptic though, not sure if that is what it's trying to tell you. I would suggest making a button somewhere on the ProfileEditViewController that calls presentModalViewController and also make sure you have a way to dismiss the UIImagePickerController (I've never used it not sure if it has one automatically).

蔚蓝源自深海 2024-09-09 01:20:50

您可能尝试同时呈现两个模态视图控制器,并且它们正在争夺动画资源。

1) 很少有任何 UI 原因需要这样做。您可以直接转到第二个视图控制器(图像选择器);然后,在关闭它之后,呈现第一个视图或视图控制器。

2)如果您确实想要两个堆叠视图控制器或视图顶部的视图控制器,请在 viewDidAppear 中设置一个计时器,以便在第一个视图控制器完成动画后显示第二个视图控制器。 (您可以在第一个视图控制器中显示空白选择器的虚拟 png 图像,以防止在第二个视图控制器上线之前显示过多闪烁。)

编辑 - 添加了一个随机代码示例:

我可能会尝试将其替换为实验:

- (void)foo {
    [self presentModalViewController: photoTaker_ animated: NO];
}

- (void)viewDidAppear: (BOOL)animated {
    NSTimer *bar = [ NSTimer scheduledTimerWithTimeInterval: (2.0f)
                             target: self  
                             selector: @selector(foo)
                             userInfo: nil
                             repeats:NO ];
}

更短的时间延迟也可能有效。

You may be trying to present two modal view controllers at the same time, and they are fighting for animation resources.

1) There is rarely any UI reason to do this. You could instead just go directly to the second view controller (the image picker); and, after dismissing it, then present the first view or view controller.

2) If you do want two stacked view controllers or a view controller on top of a view, then set a timer in viewDidAppear to present the second view controller after the first one has finished it's animation. (You could display a dummy png image of a blank picker in the first one to prevent too much display flashing until the second view controller goes live.)

EDIT - Added a random code example:

I might try substituting this as an experiment:

- (void)foo {
    [self presentModalViewController: photoTaker_ animated: NO];
}

- (void)viewDidAppear: (BOOL)animated {
    NSTimer *bar = [ NSTimer scheduledTimerWithTimeInterval: (2.0f)
                             target: self  
                             selector: @selector(foo)
                             userInfo: nil
                             repeats:NO ];
}

A shorter time delay may work as well.

朕就是辣么酷 2024-09-09 01:20:50

我刚刚遇到了同样的问题。就我而言,这是一个愚蠢的错误,我将其放在这里,以防其他人陷入同样的​​问题。

在我的选项卡式应用程序中,我删除了原始 ViewController 之一,并添加了一个带有 Storyboard 的新 ViewController 以创建“设置”部分。

这个新的 VC 必须是一个表视图 VC,即使我设计、编译和运行它也没有问题,当我更改应用程序的方向时,我不断收到“使用两阶段旋转动画”错误。

我的问题是我忘记将原始 .h 文件接口“UIViewController”更改为“UITableViewController”。

完成此操作后,我将 Storyboard 身份徽章上的类从一般值更改为我的 SettingsViewController,这就是结束。

我希望它可以帮助别人。我花了一段时间才弄清楚这一点。

干杯,

I just had the same problem. In my case was a silly mistake that I'm putting here just in case anyone else falls into that same issue.

In my tabbed app I remove one of the original ViewControllers and added a new one with Storyboard to create a "Settings" section.

This new VC had to be a table view VC and even I designed, compiled and run it without a problem, when I changed the orientation of the app I kept getting this “Using two-stage rotation animation” error.

My problem was that I forgot to change in the original .h file interface "UIViewController" for "UITableViewController".

Once this was done I changed on the Storyboard identity badge the class from the general value to my SettingsViewController and that was the end of it.

I hope it can help someone else. It took me a while to get to bottom of this.

Cheers,

秋风の叶未落 2024-09-09 01:20:50

我认为这里的警告是关于核心动画性能的。作为测试,我加载了图像选择器,没有任何操作表或其他动画正在进行,并且警告仍然存在。我认为这些警告来自图像选择器类本身,而不是来自 API 的任何滥用。

I think the warning here is about Core Animation performance. As a test, I loaded the image picker without any action sheet or other animations going on and the warnings are still there. I think these are warnings coming from the image picker class itself and not from any misuse of the API.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文