0

I think statusBarFrame and applicationFrame complement each other exactly to form the whole screen's bounds. And the frame's value is relative to the "raw" portrait orientation screen coordinates (which I think is the screen's bounds). So for example, when an iPad is rotated upside down, the output of

NSLog(@"the status bar frame is %@", 
    NSStringFromCGRect([[UIApplication sharedApplication] statusBarFrame]));

NSLog(@"the applicationFrame is %@", 
    NSStringFromCGRect([[UIScreen mainScreen] applicationFrame]));

is

the status bar frame is {{0, 1004}, {768, 20}}
the applicationFrame is {{0, 0}, {768, 1004}}

But a questions is, how come these two values that complement each other come from two different objects: the application instance and the UIScreen instance, but not from the same object? (say, both from the UIScreen object?)

4

2 回答 2

1

Simply, it's because there is only one status bar per application, but there could be multiple screens (e.g. via AirPlay) for a single application.

于 2012-09-22T15:00:52.187 回答
0

A lot of Application Kit API and also Objective-C paradigms are based around the concept of ownership.

An application owns its statusBar while the Screen owns the Application Window.

For example (No cars here) I own the table in my House but the landlord owns my House.

And more to the point Apple created the Appkit API and has created its own 'physics' and consistency . If you want your own universe and physics make your own API.

Have a look at a WWDC 2012 lecture about creating long lasting code. It goes into this really well.

于 2012-09-22T10:51:08.517 回答