English 中文(简体)
如何通过以方案方式创造窗口和观点来建立SOS?
原标题:How to set up an iOS app by programmatically creating window and views?

我愿放弃我项目中的第十一B(Nib)档案,因为这只是我是如何滚动的。 然而,我发现,我的应用方法的确是FinishLaunching WithOptions,但从未被叫作过。

I tried setting the principal class in my app s main plist like so:

<key>NSPrincipalClass</key>
<string>AppDelegate</string>

这只会导致错误:

    +[AppDelegate registerForSystemEvents]: unrecognized selector sent to class 

因此,我怎么能没有主要班子,我才有我的任命班子。

感谢。

问题回答

The easiest thing to do is just start with an appropriate project template... choosing "Empty Application" does not create a nib, but does properly setup you main.m with the following crucial line:

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

我想登记 ForSystemEvents is a private means on UIApplication, which is used, since the main category should be UIApplication or subclass it, not a responseer conform to UIApplicationDelegate.

The UIApplicationMain() call above will set your principal class to UIApplication and the delegate to your custom AppDelegate class.

但正如我所说的那样,仅仅通过使用适当的项目模板使生活变得简单。

All C based programs need main.m, which is the starting point for all programs. You can choose a blank template, or you can just create your own. Though if you create your own you do need to make sure you ve got an autorelease pool. You need to import your app delegate into main.m and I m pretty sure you need UIKit as well. Then add the following code (replacing your app delegate class as needed:

int main(int argc, char *argv[])
    {
        int retVal = 0;
        @autoreleasepool {
            retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
        }
        return retVal;
    }




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签