iPad应用程序中的UIOrientation问题

时间:2013-10-01 04:29:00

标签: iphone ipad

我正在尝试旋转一个视图.UIview包含imageview和label。当我旋转屏幕时,它会在视图上显示两个图像。

这是代码。在这里我把所有标签放在视图中加载然后我调用Orientation方法并根据横向和纵向模式中的位置放置所有标签。

 - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.


        // Code for Label Headings for meters

        //    // Speedometer Reading...
        UILabel *tempReading6 = [[UILabel alloc] initWithFrame:CGRectMake(60, 10, 300, 30)];
        self.speedometerReading = tempReading6;

        self.speedometerReading.textAlignment = UITextAlignmentCenter;
        self.speedometerReading.backgroundColor = [UIColor clearColor];
        //self.speedometerReading.text= @"Receive";
        //self.speedometerReading.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        self.speedometerReading.textColor=[UIColor purpleColor];
        [self.speedometerReading setFont:[UIFont fontWithName:@"Helvetica-Bold" size:30.0]];
        //[self.view addSubview:self.speedometerReading ];
        [self.view addSubview:self.speedometerReading ];

        UILabel *tempReading1 = [[UILabel alloc] initWithFrame:CGRectMake(415, 10, 300, 30)];
        self.speedometerReading1 = tempReading1;

        self.speedometerReading1.textAlignment = UITextAlignmentCenter;
        self.speedometerReading1.backgroundColor = [UIColor clearColor];
        //self.speedometerReading1.text= @"Test";
        //self.speedometerReading.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        self.speedometerReading1.textColor=[UIColor blueColor];
        [self.speedometerReading1 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:30.0]];
        [self.view addSubview:self.speedometerReading1 ];

        UILabel *tempReading2 = [[UILabel alloc] initWithFrame:CGRectMake(60, 340, 300, 30)];
        self.speedometerReading2 = tempReading2;

        self.speedometerReading2.textAlignment = UITextAlignmentCenter;
        self.speedometerReading2.backgroundColor = [UIColor clearColor];
        //self.speedometerReading2.text= @"Repair";
        //self.speedometerReading.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        self.speedometerReading2.textColor=[UIColor blueColor];
        [self.speedometerReading2 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:30.0]];
        [self.view addSubview:self.speedometerReading2 ];

        UILabel *tempReading3 = [[UILabel alloc] initWithFrame:CGRectMake(415, 340, 300, 30)];
        self.speedometerReading3 = tempReading3;

        self.speedometerReading3.textAlignment = UITextAlignmentCenter;
        self.speedometerReading3.backgroundColor = [UIColor clearColor];
        //self.speedometerReading3.text= @"Refurb";
        //self.speedometerReading.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        self.speedometerReading3.textColor=[UIColor purpleColor];
        [self.speedometerReading3 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:30.0]];
        [self.view addSubview:self.speedometerReading3 ];

        UILabel *tempReading4 = [[UILabel alloc] initWithFrame:CGRectMake(60, 670, 300, 30)];
        self.speedometerReading4 = tempReading4;

        self.speedometerReading4.textAlignment = UITextAlignmentCenter;
        self.speedometerReading4.backgroundColor = [UIColor clearColor];
        self.speedometerReading4.text= @"Packout";
        //self.speedometerReading.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        self.speedometerReading4.textColor=[UIColor purpleColor];
        [self.speedometerReading4 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:30.0]];
        [self.view addSubview:self.speedometerReading4 ];

        UILabel *tempReading5 = [[UILabel alloc] initWithFrame:CGRectMake(415, 670, 300, 30)];
        self.speedometerReading5 = tempReading5;

        self.speedometerReading5.textAlignment = UITextAlignmentCenter;
        self.speedometerReading5.backgroundColor = [UIColor clearColor];
        self.speedometerReading5.text= @"Shipping";
        //self.speedometerReading.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        self.speedometerReading5.textColor=[UIColor blueColor];
        [self.speedometerReading5 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:30.0]];
        [self.view addSubview:self.speedometerReading5 ];


        // Code for Meter 1 Pack value data.......

        UIImageView *backgroundImageView = [[UIImageView alloc]initWithFrame:CGRectMake(40, 30, 357,280)];
        backgroundImageView.image = [UIImage imageNamed:@"speedometer-1-2.png"];
        //backgroundImageView.backgroundColor=[UIColor whiteColor];

        [self.view addSubview:backgroundImageView];




        UIImageView *meterImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 40, 286,315)];
        meterImageView.image = [UIImage imageNamed:@"meter.png"];
        [self.view addSubview:meterImageView];


        //  Needle //
        UIImageView *imgNeedle = [[UIImageView alloc]initWithFrame:CGRectMake(200,155, 22, 110)];
        self.needleImageView = imgNeedle;

        self.needleImageView.layer.anchorPoint = CGPointMake(self.needleImageView.layer.anchorPoint.x, self.needleImageView.layer.anchorPoint.y*2);
        self.needleImageView.backgroundColor = [UIColor clearColor];
        self.needleImageView.image = [UIImage imageNamed:@"arrow.png"];
        [self.view addSubview:self.needleImageView];

        // Needle Dot //
        UIImageView *meterImageViewDot = [[UIImageView alloc]initWithFrame:CGRectMake(185, 190, 45,44)];
        meterImageViewDot.image = [UIImage imageNamed:@"center_wheel.png"];
        [self.view addSubview:meterImageViewDot];


        // Speedometer Reading //
        UILabel *tempReading = [[UILabel alloc] initWithFrame:CGRectMake(180, 260, 60, 30)];
        self.speedometerReading = tempReading;
        //[tempReading release];
        self.speedometerReading.textAlignment = UITextAlignmentCenter;
        self.speedometerReading.backgroundColor = [UIColor blackColor];
        self.speedometerReading.text= @"0";
        self.speedometerReading.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        [self.view addSubview:self.speedometerReading ];




        UILabel *temp1 = [[UILabel alloc] initWithFrame:CGRectMake(550, 260, 60, 30)];
        self.speedometerReading1 = temp1;
        //[tempReading release];
        self.speedometerReading1.textAlignment = UITextAlignmentCenter;
        self.speedometerReading1.backgroundColor = [UIColor blackColor];
        self.speedometerReading1.text= @"0";
        self.speedometerReading1.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        [self.view addSubview:self.speedometerReading1 ];



        UILabel *temp2 = [[UILabel alloc] initWithFrame:CGRectMake(180, 600, 60, 30)];
        self.speedometerReading2 = temp2;
        //[tempReading release];
        self.speedometerReading2.textAlignment = UITextAlignmentCenter;
        self.speedometerReading2.backgroundColor = [UIColor blackColor];
        self.speedometerReading2.text= @"0";
        self.speedometerReading2.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        [self.view addSubview:self.speedometerReading2 ];


        UILabel *temp3 = [[UILabel alloc] initWithFrame:CGRectMake(550, 600, 60, 30)];
        self.speedometerReading3 = temp3;
        //[tempReading release];
        self.speedometerReading3.textAlignment = UITextAlignmentCenter;
        self.speedometerReading3.backgroundColor = [UIColor blackColor];
        self.speedometerReading3.text= @"0";
        self.speedometerReading3.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        [self.view addSubview:self.speedometerReading3 ];


        UILabel *temp4 = [[UILabel alloc] initWithFrame:CGRectMake(180, 920, 60, 30)];
        self.speedometerReading4 = temp4;
        //[tempReading release];
        self.speedometerReading4.textAlignment = UITextAlignmentCenter;
        self.speedometerReading4.backgroundColor = [UIColor blackColor];
        self.speedometerReading4.text= @"0";
        self.speedometerReading4.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        [self.view addSubview:self.speedometerReading4 ];

        UILabel *temp5 = [[UILabel alloc] initWithFrame:CGRectMake(550, 920, 60, 30)];
        self.speedometerReading5 = temp5;
        //[tempReading release];
        self.speedometerReading5.textAlignment = UITextAlignmentCenter;
        self.speedometerReading5.backgroundColor = [UIColor blackColor];
        self.speedometerReading5.text= @"0";
        self.speedometerReading5.textColor = [UIColor colorWithRed:114/255.f green:146/255.f blue:38/255.f alpha:1.0];
        [self.view addSubview:self.speedometerReading5 ];



        // Set Max Value //
        self.maxVal = @"10000";

        // code snipet for dynamic label value creation.....
        UILabel *label1=[[UILabel alloc] initWithFrame:CGRectMake(260, 250, 60, 40)];
        self.label_max=label1;
        self.label_max.text=@"10000";
        [label_max setBackgroundColor:[UIColor clearColor]];


        [self.view addSubview:self.label_max ];

        UILabel *label2=[[UILabel alloc] initWithFrame:CGRectMake(200, 90, 60, 30)];
        self.label_mid=label2;
        self.label_mid.text=finalvalue;
        [self.view addSubview:self.label_mid];

        [label_mid setBackgroundColor:[UIColor clearColor]];

        UILabel *label3= [[UILabel alloc] initWithFrame:CGRectMake(120, 140, 60, 30)];
        self.lable_minmid=label3;
        self.lable_minmid.text=finalvalue2;
        [lable_minmid setBackgroundColor:[UIColor clearColor]];
        [self.view addSubview:self.lable_minmid];



        UILabel *label4=[[UILabel alloc] initWithFrame:CGRectMake(270, 140, 60, 30)];
        self.label_mid1=label4;
        // self.label_mid1.text=@"7500";
        self.label_mid1.text=finalvalue3;


        [self.view addSubview:self.label_mid1];
        [label_mid1 setBackgroundColor:[UIColor clearColor]];

        UILabel *label5= [[UILabel alloc] initWithFrame:CGRectMake(100, 250, 60, 30)];
        self.lable_min=label5;
        self.lable_min.text=@"0";

        [self.view addSubview:self.lable_min];
        [lable_min setBackgroundColor:[UIColor clearColor]];


        // Code for Meter2 RCV value data.......

        UIImageView *backgroundImageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(400, 30, 357,280)];
        backgroundImageView1.image = [UIImage imageNamed:@"speedometer-1-2.png"];
        //backgroundImageView.backgroundColor=[UIColor whiteColor];

        [self.view addSubview:backgroundImageView1];


        //  Needle //
        UIImageView *imgNeedle1 = [[UIImageView alloc]initWithFrame:CGRectMake(565,150, 22, 110)];
        self.needleImageView1 = imgNeedle1;

        self.needleImageView1.layer.anchorPoint = CGPointMake(self.needleImageView1.layer.anchorPoint.x, self.needleImageView1.layer.anchorPoint.y*2);
        self.needleImageView1.backgroundColor = [UIColor clearColor];
        self.needleImageView1.image = [UIImage imageNamed:@"arrow1.png"];
        [self.view addSubview:self.needleImageView1];

        // Needle Dot //
        UIImageView *meterImageViewDot1 = [[UIImageView alloc]initWithFrame:CGRectMake(555, 180, 45,44)];
        meterImageViewDot1.image = [UIImage imageNamed:@"center_wheel1.png"];
        [self.view addSubview:meterImageViewDot1];





        // code snipet for dynamic label value creation.........12-sep-2013...

        UILabel *label6=[[UILabel alloc] initWithFrame:CGRectMake(640, 240, 60, 40)];
        self.label_max=label6;
        self.label_max.text=@"10000";
        [label_max setBackgroundColor:[UIColor clearColor]];


        [self.view addSubview:self.label_max ];

        UILabel *label7=[[UILabel alloc] initWithFrame:CGRectMake(555, 90, 60, 30)];
        self.label_mid=label7;
        self.label_mid.text=finalvalue;
        [self.view addSubview:self.label_mid];

        [label_mid setBackgroundColor:[UIColor clearColor]];

        UILabel *label8= [[UILabel alloc] initWithFrame:CGRectMake(480, 130, 60, 30)];
        self.lable_minmid=label8;
        self.lable_minmid.text=finalvalue2;
        [lable_minmid setBackgroundColor:[UIColor clearColor]];
        [self.view addSubview:self.lable_minmid];



        UILabel *label9=[[UILabel alloc] initWithFrame:CGRectMake(630, 130, 60, 30)];
        self.label_mid1=label9;
        //self.label_mid1.text=@"7500";
        self.label_mid1.text=finalvalue3;


        [self.view addSubview:self.label_mid1];
        [label_mid1 setBackgroundColor:[UIColor clearColor]];

        UILabel *label10= [[UILabel alloc] initWithFrame:CGRectMake(470, 240, 60, 30)];
        self.lable_min=label10;
        self.lable_min.text=@"0";

        [self.view addSubview:self.lable_min];
        [lable_min setBackgroundColor:[UIColor clearColor]];





        // Code for Meter3 REFURB value data................12/9/2013........


        UIImageView *backgroundImageView2 = [[UIImageView alloc]initWithFrame:CGRectMake(40, 350, 357,280)];
        backgroundImageView2.image = [UIImage imageNamed:@"speedometer-1-2.png"];
        //backgroundImageView.backgroundColor=[UIColor whiteColor];

        [self.view addSubview:backgroundImageView2];


        //  Needle //
        UIImageView *imgNeedle2 = [[UIImageView alloc]initWithFrame:CGRectMake(208,460, 22, 110)];
        self.needleImageView2 = imgNeedle2;

        self.needleImageView2.layer.anchorPoint = CGPointMake(self.needleImageView2.layer.anchorPoint.x, self.needleImageView2.layer.anchorPoint.y*2);
        self.needleImageView2.backgroundColor = [UIColor clearColor];
        self.needleImageView2.image = [UIImage imageNamed:@"arrow2.png"];
        [self.view addSubview:self.needleImageView2];

        // Needle Dot //
        UIImageView *meterImageViewDot2 = [[UIImageView alloc]initWithFrame:CGRectMake(190, 500, 45,44)];
        meterImageViewDot2.image = [UIImage imageNamed:@"center_wheel2.png"];
        [self.view addSubview:meterImageViewDot2];

        // code snipet for dynamic label value creation.........3-sep-2013...

        UILabel *label11=[[UILabel alloc] initWithFrame:CGRectMake(260, 550, 60, 40)];
        self.label_max=label11;
        self.label_max.text=@"10000";
        [label_max setBackgroundColor:[UIColor clearColor]];


        [self.view addSubview:self.label_max ];

        UILabel *label12=[[UILabel alloc] initWithFrame:CGRectMake(195, 400, 60, 30)];
        self.label_mid=label12;
        self.label_mid.text=finalvalue;
        [self.view addSubview:self.label_mid];

        [label_mid setBackgroundColor:[UIColor clearColor]];

        UILabel *label13= [[UILabel alloc] initWithFrame:CGRectMake(120, 450, 60, 30)];
        self.lable_minmid=label13;
        self.lable_minmid.text=finalvalue2;
        [lable_minmid setBackgroundColor:[UIColor clearColor]];
        [self.view addSubview:self.lable_minmid];



        UILabel *label14=[[UILabel alloc] initWithFrame:CGRectMake(270, 450, 60, 30)];
        self.label_mid1=label14;
        //self.label_mid1.text=@"7500";
        self.label_mid1.text=finalvalue3;


        [self.view addSubview:self.label_mid1];
        [label_mid1 setBackgroundColor:[UIColor clearColor]];

        UILabel *label15= [[UILabel alloc] initWithFrame:CGRectMake(120, 560, 60, 30)];
        self.lable_min=label15;
        self.lable_min.text=@"0";

        [self.view addSubview:self.lable_min];
        [lable_min setBackgroundColor:[UIColor clearColor]];

        // Code for Meter4 REP value data...........12/9/2013........


        UIImageView *backgroundImageView3 = [[UIImageView alloc]initWithFrame:CGRectMake(400, 350, 357,280)];
        backgroundImageView3.image = [UIImage imageNamed:@"speedometer-1-2.png"];
        //backgroundImageView.backgroundColor=[UIColor whiteColor];

        [self.view addSubview:backgroundImageView3];


        //  Needle //
        UIImageView *imgNeedle3 = [[UIImageView alloc]initWithFrame:CGRectMake(560,470, 22, 110)];
        self.needleImageView3 = imgNeedle3;

        self.needleImageView3.layer.anchorPoint = CGPointMake(self.needleImageView3.layer.anchorPoint.x, self.needleImageView3.layer.anchorPoint.y*2);
        self.needleImageView3.backgroundColor = [UIColor clearColor];
        self.needleImageView3.image = [UIImage imageNamed:@"arrow3.png"];
        [self.view addSubview:self.needleImageView3];

        // Needle Dot //
        UIImageView *meterImageViewDot3 = [[UIImageView alloc]initWithFrame:CGRectMake(550, 500, 45,44)];
        meterImageViewDot3.image = [UIImage imageNamed:@"center_wheel3.png"];
        [self.view addSubview:meterImageViewDot3];




        // code snipet for dynamic label value creation....
        UILabel *label16=[[UILabel alloc] initWithFrame:CGRectMake(620, 560, 60, 40)];
        self.label_max=label16;
        self.label_max.text=@"10000";
        [label_max setBackgroundColor:[UIColor clearColor]];


        [self.view addSubview:self.label_max ];

        UILabel *label17=[[UILabel alloc] initWithFrame:CGRectMake(555, 420, 60, 30)];
        self.label_mid=label17;
        self.label_mid.text=finalvalue;
        [self.view addSubview:self.label_mid];

        [label_mid setBackgroundColor:[UIColor clearColor]];

        UILabel *label18= [[UILabel alloc] initWithFrame:CGRectMake(470, 450, 60, 30)];
        self.lable_minmid=label18;
        self.lable_minmid.text=finalvalue2;
        [lable_minmid setBackgroundColor:[UIColor clearColor]];
        [self.view addSubview:self.lable_minmid];



        UILabel *label19=[[UILabel alloc] initWithFrame:CGRectMake(620, 450, 60, 30)];
        self.label_mid1=label19;
        //self.label_mid1.text=@"7500";
        self.label_mid1.text=finalvalue3;


        [self.view addSubview:self.label_mid1];
        [label_mid1 setBackgroundColor:[UIColor clearColor]];

        UILabel *label20= [[UILabel alloc] initWithFrame:CGRectMake(480, 560, 60, 30)];
        self.lable_min=label20;
        self.lable_min.text=@"0";

        [self.view addSubview:self.lable_min];
        [lable_min setBackgroundColor:[UIColor clearColor]];




        // Code for Meter5 SHIP value data.......

        UIImageView *backgroundImageView4 = [[UIImageView alloc]initWithFrame:CGRectMake(40, 680, 357,280)];
        backgroundImageView4.image = [UIImage imageNamed:@"speedometer-1-2.png"];
        //backgroundImageView.backgroundColor=[UIColor whiteColor];

        [self.view addSubview:backgroundImageView4];


        //  Needle //
        UIImageView *imgNeedle4 = [[UIImageView alloc]initWithFrame:CGRectMake(200,800, 22, 110)];
        self.needleImageView4 = imgNeedle4;

        self.needleImageView4.layer.anchorPoint = CGPointMake(self.needleImageView4.layer.anchorPoint.x, self.needleImageView4.layer.anchorPoint.y*2);
        self.needleImageView4.backgroundColor = [UIColor clearColor];
        self.needleImageView4.image = [UIImage imageNamed:@"arrow4.png"];
        [self.view addSubview:self.needleImageView4];

        // Needle Dot //
        UIImageView *meterImageViewDot4 = [[UIImageView alloc]initWithFrame:CGRectMake(188, 830, 45,44)];
        meterImageViewDot4.image = [UIImage imageNamed:@"center_wheel4.png"];
        [self.view addSubview:meterImageViewDot4];



        // code snipet for dynamic label value creation.....

        UILabel *label21=[[UILabel alloc] initWithFrame:CGRectMake(270, 890, 60, 40)];
        self.label_max=label21;
        self.label_max.text=@"10000";
        [label_max setBackgroundColor:[UIColor clearColor]];


        [self.view addSubview:self.label_max ];

        UILabel *label22=[[UILabel alloc] initWithFrame:CGRectMake(195, 730, 60, 30)];
        self.label_mid=label22;
        self.label_mid.text=finalvalue;
        [self.view addSubview:self.label_mid];

        [label_mid setBackgroundColor:[UIColor clearColor]];

        UILabel *label23= [[UILabel alloc] initWithFrame:CGRectMake(110, 780, 60, 30)];
        self.lable_minmid=label23;
        self.lable_minmid.text=finalvalue2;
        [lable_minmid setBackgroundColor:[UIColor clearColor]];
        [self.view addSubview:self.lable_minmid];



        UILabel *label24=[[UILabel alloc] initWithFrame:CGRectMake(280, 780, 60, 30)];
        self.label_mid1=label24;
        //self.label_mid1.text=@"7500";
        self.label_mid1.text=finalvalue3;


        [self.view addSubview:self.label_mid1];
        [label_mid1 setBackgroundColor:[UIColor clearColor]];

        UILabel *label25= [[UILabel alloc] initWithFrame:CGRectMake(110, 890, 60, 30)];
        self.lable_min=label25;
        self.lable_min.text=@"0";

        [self.view addSubview:self.lable_min];
        [lable_min setBackgroundColor:[UIColor clearColor]];

        // Code for Meter6 TST-RSLT value data.......Alok kumar.........12/9/2013........


        UIImageView *backgroundImageView5 = [[UIImageView alloc]initWithFrame:CGRectMake(400, 680, 357,280)];
        backgroundImageView5.image = [UIImage imageNamed:@"speedometer-1-2.png"];
        //backgroundImageView.backgroundColor=[UIColor whiteColor];

        [self.view addSubview:backgroundImageView5];


        //  Needle //
        UIImageView *imgNeedle5 = [[UIImageView alloc]initWithFrame:CGRectMake(560,800, 22, 110)];
        self.needleImageView5 = imgNeedle5;

        self.needleImageView5.layer.anchorPoint = CGPointMake(self.needleImageView5.layer.anchorPoint.x, self.needleImageView5.layer.anchorPoint.y*2);
        self.needleImageView5.backgroundColor = [UIColor clearColor];
        self.needleImageView5.image = [UIImage imageNamed:@"arrow5.png"];
        [self.view addSubview:self.needleImageView5];

        // Needle Dot //
        UIImageView *meterImageViewDot5 = [[UIImageView alloc]initWithFrame:CGRectMake(550, 830, 45,44)];
        meterImageViewDot5.image = [UIImage imageNamed:@"center_wheel5.png"];
        [self.view addSubview:meterImageViewDot5];


        // code snipet for dynamic label value creation.....Alok kumar.....12-sep-2013...

        UILabel *label26=[[UILabel alloc] initWithFrame:CGRectMake(640, 890, 60, 40)];
        self.label_max=label26;
        self.label_max.text=@"10000"; // label for meters max value.......
        [label_max setBackgroundColor:[UIColor clearColor]];


        [self.view addSubview:self.label_max ];

        UILabel *label27=[[UILabel alloc] initWithFrame:CGRectMake(555, 730, 60, 30)];
        self.label_mid=label27;
        self.label_mid.text=finalvalue;
        [self.view addSubview:self.label_mid];

        [label_mid setBackgroundColor:[UIColor clearColor]];

        UILabel *label28= [[UILabel alloc] initWithFrame:CGRectMake(460, 780, 60, 30)];
        self.lable_minmid=label28;
        self.lable_minmid.text=finalvalue2;
        [lable_minmid setBackgroundColor:[UIColor clearColor]];
        [self.view addSubview:self.lable_minmid];



        UILabel *label29=[[UILabel alloc] initWithFrame:CGRectMake(650, 780, 60, 30)];
        self.label_mid1=label29;
        //self.label_mid1.text=@"7500";
        self.label_mid1.text=finalvalue3;


        [self.view addSubview:self.label_mid1];
        [label_mid1 setBackgroundColor:[UIColor clearColor]];

        UILabel *label30= [[UILabel alloc] initWithFrame:CGRectMake(470, 890, 60, 30)];
        self.lable_min=label30;
        self.lable_min.text=@"0";

        [self.view addSubview:self.lable_min];
        [lable_min setBackgroundColor:[UIColor clearColor]];
        //
        //



        self.maxVal1=@"10000";
        self.maxVal2=@"10000";
        self.maxVal3=@"10000";
        self.maxVal4=@"10000";
        self.maxVal5=@"10000";



        /// Set Needle pointer initialy at zero //
        [self rotateIt:-118.4];

        // Set previous angle //
        self.prevAngleFactor = -118.4;

        // Set Speedometer Value //
        [self setSpeedometerCurrentValue];
        //    [self speedometerCurrentValue1];
        //    [self speedometerCurrentValue2];
        //    [self speedometerCurrentValue3];
        //    [self speedometerCurrentValue4];
        //    [self speedometerCurrentValue5];
    }

        }
    }

1 个答案:

答案 0 :(得分:0)

你的viewDidLoad方法非常非常长并且包含大量重复代码 - 我无法解决问题所在。但是,如果将其分解为较小的可重用方法,您可能会发现问题所在。将来维护起来会更容易。

或者,您可以尝试在Xcode中的Storyboard或XIB文件中构建用户界面。然后,您可以定义自动布局约束,以定义用户界面如何响应旋转等。