简体   繁体   English

XCode 4.5 iOS 6.0模拟器和旋转问题

[英]XCode 4.5 iOS 6.0 simulator and rotation issues

I have application made for iOS 4.2 and I was doing development in XCode 4.3.3 and testing it with iPhone 5.1 Simulator and everything worked fine. 我已经为iOS 4.2做了应用程序,我正在使用XCode 4.3.3进行开发并使用iPhone 5.1模拟器进行测试,一切正常。 Recently I decided to test how application runs on iOS 6.0. 最近我决定测试应用程序在iOS 6.0上运行的方式。 When trying this, I face two problems: 在尝试这个时,我面临两个问题:

  1. So, I open application with XCode 4.5 and run it on iPhone 6.0 Simulator. 因此,我使用XCode 4.5打开应用程序并在iPhone 6.0 Simulator上运行它。 I have problems oft with starting application. 我有启动应用程序的问题。 XCode just says: Finished running on iPhone 6.0 Simulator, stop button is grayed (like app is not running) and iPhone simulator just shows black screen and nothing happens. XCode只是说:完成在iPhone 6.0模拟器上运行,停止按钮是灰色的(就像应用程序没有运行)和iPhone模拟器只显示黑屏,没有任何反应。 I have to CMD+Q it. 我要CMD + Q吧。 And this is for me HUGE problem , since I manage to run application successfully randomly after lots of failures. 这对我来说是个巨大的问题 ,因为我设法在很多失败之后成功地随机运行应用程序。

  2. Eventually and sometimes, application runs without problems and I see that emulator is running my application. 最终,有时,应用程序运行没有问题,我看到模拟器正在运行我的应用程序。 Application is made in landscape mode only. 应用程序仅以横向模式进行。 But when simulator runs application, it stays in portrait mode and shows application designed for landscape screen in portrait mode. 但是当模拟器运行应用程序时,它将保持纵向模式并显示为纵向模式下的横向屏幕设计的应用程序。 I have set Supported Interface Orientations to both landscape variants and in Application-Info.plist are these two landscape orientations also listed. 我已将支持接口方向设置为两个横向变体,而在Application-Info.plist中也列出了这两个横向方向。

Does anyone know what's happening and possible solution? 有谁知道发生了什么和可能的解决方案?

Many thanks in advance. 提前谢谢了。


[edit #1: Added All Output console message] [编辑#1:添加了所有输出控制台消息]

Console message (for problem 1 which now keeps occurring) says: 控制台消息(对于现在一直存在的问题1)说:

error: failed to attach to process ID 0

[edit #2: Small progress in solving 1st problem] [编辑#2:解决第一个问题的小进展]

Okay, strange things are happening. 好的,奇怪的事情正在发生。 First thing I did in order to eliminate error from edit #1 was: 为了消除编辑#1中的错误,我做的第一件事是:

In XCode go to: Product -> Edit Scheme -> Run [AppName].app -> Debugger and change it from LLDB to GDB 在XCode中转到: 产品 - >编辑方案 - >运行[AppName] .app - > Debugger并将其从LLDB更改为GDB

After this, error from edit #1 is gone, BUT there's new problem. 在此之后,编辑#1的错误消失了, 但是出现了新的问题。 After I run application now I get status message in XCode: Attaching to [AppName] and XCode is stuck on that action. 现在我运行应用程序后,我在XCode中获取状态消息: 附加到[AppName]并且XCode停留在该操作上。

If anyone gives me an answer, I want to say that I tried everything from the list below: 如果有人给我一个答案,我想说我尝试了以下列表中的所有内容:

  • Go to Window -> Organizer -> Derived Data -> Delete 转到窗口 - >管理器 - >派生数据 - >删除
  • Go to Window -> Organizer -> [ProjectName] and delete it completely and then reopen it 转到窗口 - >管理器 - > [ProjectName]并完全删除它,然后重新打开它
  • Reset iPhone simulator settings 重置iPhone模拟器设置
  • Reset iPhone simulator + Clean Build + Quit Simulator + Run project 重置iPhone模拟器+清洁构建+退出模拟器+运行项目
  • Quit XCode + reboot Mac + reopen XCode and run application again 退出XCode +重启Mac +重新打开XCode并再次运行应用程序

and all kinds of these action permutations. 以及各种这些动作排列。 Simply, I always see this problem. 简单地说,我总是看到这个问题。 Best thing which happened to me was during this combination: 发生在我身上的最好的事情是在这个组合中:

Open only XCode without opening project -> Go to Window -> Organizer -> [ProjectName] and delete it completely -> Quit XCode -> Open iPhone simulator and reset settings -> Quit iPhone simulator -> reboot Mac -> reopen XCode and run application 只打开XCode而不打开项目 - >转到窗口 - >管理器 - > [ProjectName]并完全删除它 - >退出XCode - >打开iPhone模拟器并重置设置 - >退出iPhone模拟器 - >重启Mac - >重新打开XCode并运行应用

Sometimes in this case simulator managed to run my application right away, which is great. 有时在这种情况下,模拟器设法立即运行我的应用程序,这很好。 But after closing simulator and running application from XCode again (without doing anything between these two actions), XCode is stuck again on Attaching to [AppName] and won't start simulator with my application. 但是在关闭模拟器并再次从XCode运行应用程序之后(在这两个操作之间没有做任何事情),XCode再次停留在附加到[AppName]并且不会启动我的应用程序的模拟器。

Although simulator won't start with my application from XCode, application itself is stored on simulator, and if I run simulator separately and start my application manually, application manages to start, but with 2nd problem I have in my problem description - layout issue. 虽然模拟器不会从我的应用程序从XCode开始,但应用程序本身存储在模拟器上,如果我单独运行模拟器并手动启动我的应用程序,应用程序设法启动,但第二个问题我在我的问题描述 - 布局问题。


[edit #3: XCode version info] [编辑#3:XCode版本信息]

I forgot to mention my XCode version: Xcode Version 4.5 (4G144l) 我忘了提到我的XCode版本: Xcode Version 4.5(4G144l)


[edit #4: "Solution"] [编辑#4:“解决方案”]

I found "solution" (I say "solution", since I haven't managed to find one in current XCode version). 我找到了“解决方案”(我说“解决方案”,因为我还没有在当前的XCode版本中找到一个)。

I have just downloaded XCode Version 4.5 (4G182) and run my application normally (without changing Debugger to GDB) and everything's working fine except layout problem, which is definitely present because some changes made to iOS 6.0 comparing to iOS 5. I suppose this in fact is solution, since this version of XCode I used originally won't be used, since it was some of beta versions. 我刚刚下载了XCode版本4.5(4G182)并且正常运行我的应用程序(没有将调试器更改为GDB)并且除了布局问题之外一切正常,这肯定是因为iOS 6.0与iOS 5相比有所改变。我想这是事实上是解决方案,因为我最初使用的这个版本的XCode将不会被使用,因为它是一些beta版本。

So, 1st problem is solved, still didn't manage to solve problem with layout. 那么,第一个问题解决了,还没有解决布局问题。


[edit #5: Final solution] [编辑#5:最终解决方案]

Okay, 2nd problem solved. 好的,第二个问题解决了。 For all informations about my 2nd problem, here's the answer on this link: http://yusinto.blogspot.de/2012/08/ios-6-auto-rotate-and-orientation.html 关于我的第二个问题的所有信息,这里是这个链接的答案:http: //yusinto.blogspot.de/2012/08/ios-6-auto-rotate-and-orientation.html

Like I said in my edits, solution to my 1st problem was updating XCode to Version 4.5 (4G182) . 就像我在编辑中说的那样,解决我的第一个问题是将XCode更新为4.5版(4G182) Solution to my 2nd question was replacing deprecated iOS 5 method: 我的第二个问题的解决方案是替换弃用的iOS 5方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

with 2 new methods introduced in iOS 6: 在iOS 6中引入了2种新方法:

- (NSUInteger)supportedInterfaceOrientations
- (BOOL)shouldAutorotate

After that, app works just fine. 之后,应用程序工作正常。

[edit #1: Adding working sample of landscape only app with iOS 5 and iOS 6 support] [编辑#1:添加仅支持iOS 5和iOS 6的横向应用的工作示例]

AppDelegate.m AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.
    self.viewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
    self.window.rootViewController = self.viewController; 
    [self.window makeKeyAndVisible];

    return YES;
}

MainViewController.m MainViewController.m

#pragma mark - Orientation support

- (BOOL)shouldAutorotate {

    return YES;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

    return UIInterfaceOrientationLandscapeLeft;
}

Deleting the \\Library\\Application Support\\iPhone Simulator folder entirely and run simulator from XCode works for me. 完全删除\\Library\\Application Support\\iPhone Simulator文件夹并从XCode运行模拟器适合我。

Now I can run iOS 6.0 Simulator from XCode. 现在我可以从XCode运行iOS 6.0 Simulator。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM