macos 将 iOS (iPhone) 应用程序移植到 Mac?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4579849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
port an iOS (iPhone) app to mac?
提问by William Jockusch
Is there a preferred way to go about this?
有没有更好的方法来解决这个问题?
The app in question is not too large . . . single-player game that I wrote over the course of a couple of months.
有问题的应用程序不是太大。. . 我在几个月的时间里写的单人游戏。
EDIT: I should add that I have no experience with mac development . . . outside of what comes naturally with being an iOS developer.
编辑:我应该补充一点,我没有 mac 开发经验。. . 除了成为 iOS 开发者的本性之外。
EDIT: Classes heavily used in the game: subclasses of NSObject, UIView, and UIViewController. I don't know much about NSView, but I'm pretty sure all the UIView stuff will work in that class. Also some use of UITableViewController. I do also have Game Center, but I can leave that part out for now. There is no multi-touch.
编辑:游戏中大量使用的类:NSObject、UIView 和 UIViewController 的子类。我不太了解 NSView,但我很确定所有 UIView 的东西都可以在那个类中工作。还有一些 UITableViewController 的使用。我也有游戏中心,但我现在可以不考虑那部分。没有多点触控。
EDIT: My graphics is all stuff that is in the QuartzCore and CoreGraphics frameworks. I do have a moderate view hierarchy.
编辑:我的图形是 QuartzCore 和 CoreGraphics 框架中的所有内容。我确实有一个适度的视图层次结构。
EDIT: If you are doing such a port, you may also be interested in the issue of memory management
编辑:如果您正在做这样的端口,您可能也对内存管理问题感兴趣
采纳答案by Fattie
There's no easy way.It's that simple. Depressingly, you simply have to become good at programming the Mac.
"I'm pretty sure all the UIView stuff will work in that class"-- unfortunately, no. Everything is different that enough you have to work hard.
没有简单的方法。就这么简单。令人沮丧的是,您只需要擅长为 Mac 编程。
“我很确定所有 UIView 的东西都可以在那个类中工作”——不幸的是,没有。一切都不同,你必须努力工作。
It's not a fun gig. Make sure you really, really think it's worth it financially.
这不是一场有趣的演出。确保你真的,真的认为这在经济上是值得的。
Apart from anything else, be aware of the "sibling views don't work on OSX" problem if you stack up a lot of views in your iOS app. Essentially, you will have to change to using layers (instead of simply views) on the Mac if you rely on nested hierarchies of views here and there on the phone!
除此之外,如果您在 iOS 应用程序中堆积了大量视图,请注意“兄弟视图在 OSX 上不起作用”的问题。从本质上讲,如果您依赖手机上到处嵌套的视图层次结构,您将不得不在 Mac 上更改为使用层(而不是简单的视图)!
Click this link: Is there a proper way to handle overlapping NSView siblings?for the gory details on that particular problem!
单击此链接:是否有正确的方法来处理重叠的 NSView 兄弟姐妹?有关该特定问题的详细信息!
回答by Lloyd Dewolf
http://chameleonproject.org/UIKit for Mac from Iconfactory is worth checking out.
http://chameleonproject.org/Iconfactory 的 UIKit for Mac 值得一试。
"Chameleon is a work in progress. The framework currently implements about 60% of UIKit after nine months of work."
“Chameleon 是一项正在进行中的工作。经过九个月的工作,该框架目前实现了大约 60% 的 UIKit。”
回答by Dave R
You may have a lot of work ahead of you. While purely algorithmic classes will port without any change, anything that touches UIKit will likely need to be rewritten, or heavily adapted. The UI class design pattern on OSX is that of a relationship between views, where your code is responsible for managing controllers; while on iOS it is one of a relationship between view controllers, where view management is implied.
你可能有很多工作要做。虽然纯算法类将无需任何更改即可移植,但任何涉及 UIKit 的内容都可能需要重写或大量调整。OSX 上的 UI 类设计模式是视图之间的关系,您的代码负责管理控制器;而在 iOS 上,它是视图控制器之间的一种关系,其中隐含了视图管理。
Of course, as BoltClock mentioned, you have the issue of interaction. Since touch no longer works, you will probably need to work on your interaction model first, even before you start porting.
当然,正如 BoltClock 提到的,你有交互的问题。由于触摸不再有效,您可能需要先处理交互模型,甚至在开始移植之前。
回答by hotpaw2
There exists an open source (BSD) UMEKitlibrary that may help with porting a few UI classes, but you may have to rewrite a fair amount of the UI to better handle the mouse/keyboard/multi-window/menu GUI environment. Basic NSObjects, and some Open GL and Quartz graphics rendering, may port with only minor touch ups.
存在一个开源 (BSD) UMEKit库,它可能有助于移植一些 UI 类,但您可能需要重写大量 UI 以更好地处理鼠标/键盘/多窗口/菜单 GUI 环境。基本的 NSObjects 和一些 Open GL 和 Quartz 图形渲染,可能只需要少量修改就可以移植。
回答by orb
As others say, porting can be a chore. The general techniques work, though. You redesign the interface in Interface Builder (where applicable) and check what the different controls are called (CocoaTouch only has a small subset of typical desktop controls). UI* typically becomes NS*. Tableview delegation is similar, so it will probably be easy.
正如其他人所说,移植可能是一件苦差事。不过,一般技术是有效的。您在 Interface Builder 中重新设计界面(如果适用)并检查不同控件的名称(CocoaTouch 只有典型桌面控件的一小部分)。UI* 通常会变成 NS*。Tableview 委托是类似的,所以它可能会很容易。
I'll have to recommend the Aaron Hillegass book as usual. It's a great introduction to Mac development, and knowing iOS development gives you an edge.
我将不得不像往常一样推荐 Aaron Hillegass 的书。这是对 Mac 开发的一个很好的介绍,了解 iOS 开发会给你带来优势。
Since it's a game, you probably need to consider how to do fullscreen mode. The game doesn't necessarily take up the entire screen anymore, and you shouldn't force it. A whole new set of preferences will now be necessary. There is of course some "fun" involved now that there are new ways to handle resolution listing/changing with Snow Leopard (with the previous ways giving you deprecation warnings).
既然是游戏,你可能需要考虑如何做全屏模式。游戏不一定会占据整个屏幕,您不应该强迫它。现在需要一套全新的偏好。现在当然有一些“乐趣”,因为有新的方法来处理使用 Snow Leopard 的分辨率列表/更改(以前的方法会给你弃用警告)。
Just accept that there will be a possibly lengthy transition period until everything "clicks" :)
接受可能会有一个漫长的过渡期,直到一切都“点击”:)