Michael Schmidt
Michael Schmidt

Reputation: 3521

How can I resize a complete view in iOS - from iPad to iPhone with all content proportionally?

I have a view optimized for an iPad. I want to show exactly this same view on an iPhone (yes, I know that the view will be small - this is ok in this case. Black bars on the left and right because of the aspect ratio difference are ok as well).

How can I scale the iPad view for display on iPhone screen? With all content resized proportionally, including fonts, tables, images?

Upvotes: 0

Views: 458

Answers (2)

Meet
Meet

Reputation: 4934

How about using the feature of Interface builder to help you through this!!

Make two XIB files, such as, WebView_iPhoneVC and WebView_iPadVC, and set the webview autoresizing for the view in Interface Builder.

Call the XIB's condionally,

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
WebView_iPhoneVC *webviewVC_iPhone = [[WebView_iPhoneVC alloc] initWithNibName:@"WebView_iPhoneVC" bundle:nil];
[self.navigationController pushViewController:webviewVC_iPhone animated:YES];
[webviewVC_iPhone release];
}

else {

WebView_iPadVC *webviewVC_iPadVC = [[WebView_iPadVC alloc] initWithNibName:@"WebView_iPadVC" bundle:nil];
[self.navigationController pushViewController:webviewVC_iPadVC animated:YES];
[webviewVC_iPadVC release];
}

Upvotes: 0

Inder Kumar Rathore
Inder Kumar Rathore

Reputation: 39988

Just define macros

#define X_WIDTH  320/768
#define Y_HEIGHT 480/1024

Multiply all your x and width parameter with X_WIDTH and all your y and height parameters with Y_HEIGHT
Or more generalized is you define variables like

CGRect screenSize = [[UIScreen mainScreen] bounds];
float x_width = screenSize.widht/768;
float y_height = screenSize.height/1024;

Upvotes: 1

Related Questions