iPhone view won't scale to fit iPad screen
I'm having a bit of trouble with, as silly as all things, a progress view overlay.
I've created a subclass of UIViewController with a XIB with a black 50% opaque background and an activity indicator in the middle of it, I can get it to appeaer and disappear when my remote data class tries to get data from the remote server etc.
It works fine on the iPhone, scales and rotates.
However, when I fire it up in iPad simulator or on device, the square only fills the upper left corner of the screen and won't resize to to fit the display.
But, all my other views are created in the same way, including all the tableview's that this will sit over.
My app initialises a table view with a single cell that says "Loading..." and then call开发者_如何学Cs the remote data services class which then does the following:
progress = [[ProgressActivityViewController alloc] initWithNibName:@"ProgressActivityViewController" bundle:nil];
UIViewController *dlg = (UIViewController *)self.delegate;
[dlg.view addSubview:progress.view];
NB: progress is set up in the .h file as ProgressActivityViewController) It's the remote data services class that is adding and removing the subview, when you init the RemoteData class, you pass it 'self' as the delegate so it can talk to it through a protocol.
I know this needs some other type checking with 'isKindOfClass' etc which I can add in later but I need to get the simple view to stretch to full screen.
This code does work and puts the view on the screen but it just doesn't fill the screen on the iPad
The source for the activity indicator example i've used is at this link: http://tapadoo.com/2009/iphone-how-to-do-full-screen-activity-status/
Do you have an iPad paradigm .xib in your project, and also listed that iPad xib file in your app's plist? If not, you may only get a window in the top left corner.
Create a new Universal iPhone/iPad project, and the template will show you where to mention the iPad xib in the plist.
精彩评论