0

UITabBar在 iPhone 和 iPad 应用程序中使用 a,但是当我进入横向模式时,自动调整大小在 iPad 上不起作用(它在 iPhone 上工作正常)。

{
    tabBarController =[[UITabBarController alloc]init];
    tabBarController.delegate=self;
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:navController1,navController2, navController3,navController4,navController5,nil];
    tabBarController.selectedViewController = navController1;
    imgTab = [[UIImageView alloc]initWithFrame:CGRectMake(0,0,768.0,51)];
    [imgTab setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleBottomMargin |   UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin]; imgTab.image=[UIImage imageNamed:@"footerbg.jpg"];
    [tabBarController.tabBar addSubview:imgTab];
    accountImg=[[UIImageView alloc]initWithFrame:CGRectMake(150.0,5.0,29.0,29.0)];
    [accountImg setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleBottomMargin |   UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
    accountImg.image=[UIImage imageNamed:@"click11.png"];
    UITabBarItem *tabItem = [[[tabBarController tabBar] items] objectAtIndex:0];
    [tabItem setTitle:@"Task"];
    [imgTab addSubview:accountImg];
    staffImg=[[UIImageView alloc]initWithFrame:CGRectMake(255,5.0,29.0,29.0)];
    staffImg.image=[UIImage imageNamed:@"spreadsheet11-1.png"];
    UITabBarItem *tabItem1 = [[[tabBarController tabBar] items] objectAtIndex:1];
    [tabItem1 setTitle:@"SpreadSheet"];
    [staffImg setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleBottomMargin |   UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
    [imgTab addSubview:staffImg];
    taskImg=[[UIImageView alloc]initWithFrame:CGRectMake(370.0,5.0,29.0,29.0)];
    taskImg.image=[UIImage imageNamed:@"calendar2.png"];
    UITabBarItem *tabItem2 = [[[tabBarController tabBar] items] objectAtIndex:2];
    [tabItem2 setTitle:@"Calendar"];
    [taskImg setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleBottomMargin |   UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
    [imgTab addSubview:taskImg];
    spreadImg =[[UIImageView alloc]initWithFrame:CGRectMake(472.0,5.0,29.0,29.0)];
    spreadImg.image=[UIImage imageNamed:@"message22.png"];
    UITabBarItem *tabItem3 = [[[tabBarController tabBar] items] objectAtIndex:3];
    [tabItem3 setTitle:@"Message"];
    [spreadImg setAutoresizingMask: UIViewAutoresizingFlexibleHeight |   UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleBottomMargin |   UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
    [imgTab addSubview:spreadImg];

}
4

1 回答 1

0

我在此代码中没有看到您为 UITabBar 配置 UIAutoresizingMask 的任何地方,仅针对其中的项目。

于 2013-01-23T17:33:34.323 回答