我通过添加iPad.XIB并在源代码编辑器模式下用IBIPadFramework替换IBCocoaTouchFramework,将我的xib转换为iPad特定的xib。我的观点仍然没有覆盖整个屏幕,视图周围有很多空白区域,而且这些视图分辨率也不好,除了我上面提到的以外,我还需要做更多的事情。
编辑:
我已经为iPad创建了新项目,它的工作正常,如果我在旧项目(iPhone)中为iPad添加新的xib,它无法正常工作,是否有与项目相关的内容需要更改?
感谢。
答案 0 :(得分:2)
如果出现小视图,我认为你的应用程序不支持ipad平台,即它不是非逆转的应用程序。创建新的unversal应用程序并在其中添加所有viewcontroller类和xib。 - 王子
答案 1 :(得分:1)
您应首先使用波纹管代码检查设备,现在您创建两个xib,使用相同的第一类xib用于ipad,第二个用于iphone,并使用设备智能加载..
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
//iphone
}
else
{
//ipad
}
例如
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
masterViewController = [[cntrMasterViewController alloc] initWithNibName:@"cntrMasterViewController_iPhone" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
// loadingView =[LoadingView loadingViewInView:masterViewController.view:@"Please Wait.."];
//masterViewController.view.userInteractionEnabled=NO;
[self.window makeKeyAndVisible];
self.window.rootViewController = self.navigationController;
[self.window addSubview:self.navigationController.view];
}
else
{
cntrMasterViewController *masterViewController = [[[cntrMasterViewController alloc] initWithNibName:@"cntrMasterViewController_iPad" bundle:nil] autorelease];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
UIViewController *viewController1 = [[cntrMasterViewController alloc] initWithNibName:@"cntrMasterViewController_iPad" bundle:nil];
[self.window makeKeyAndVisible];
self.window.rootViewController = self.navigationController;
[self.window addSubview:self.viewController1.view];
}
答案 2 :(得分:1)
您必须再次设置视图的子视图框架,使其看起来适合iPad屏幕。在iPad的xib或programmaticaly中进行,使用nitin的方法根据您正在使用的设备加载视图
答案 3 :(得分:0)
只需检查您输入的xib
名称是否正确
yourViewController = [[yourViewController alloc] initWithNibName:@"yourIpadNibName" bundle:nil];
只关注yourIpadNibName