更改框架后视图未更新

时间:2016-09-05 08:31:07

标签: ios objective-c

@implementation LandlineViewController

- (void)viewDidLoad {

    [super viewDidLoad];
    self.txtOperator.delegate = self;
    self.txtSTD.delegate = self;
    self.txtLandlindNumber.delegate = self;
    self.txtAccountNumber.delegate = self;
    self.txtLLI_LLC.delegate = self;
    self.txtAmount.delegate = self;
    self.txtAmount.textFieldInsets = CGPointMake(15, 10);
    self.isTouchEventEnabled = YES;
    [self allLblHidden];
    [self allTextHidden];
    _myOperatorType=LandlineViewControllerOperatorTypeNotSelected;
    [self performSelector:@selector(configureUIForSelectedOperatorType) withObject:nil afterDelay:0.5f];


}

- (void) refreshViewOnAppear {
    self.txtOperator.text=@"";
    self.rupeeSymble.hidden=YES;
     _myOperatorType=LandlineViewControllerOperatorTypeNotSelected;
    [self resignFirstResponder];
    [self performSelector:@selector(configureUIForSelectedOperatorType) withObject:nil afterDelay:0.5f];
}

- (void) updateViewOnDisappear {

}

- (void)setSelectedMobileOperator:(LandlineOperator *)selectedMobileOperator {

    NSDictionary *utilityCreditDestination = selectedMobileOperator.parameterList;
    TPLog(@"%@ utilityCreditDestination",utilityCreditDestination);

    UtilityTransaction *trancastion = [[Utilities sharedUtilities] tobeUtilityTransaction];
    trancastion.operatorId = selectedMobileOperator.operatorId;
    _selectedMobileOperator = selectedMobileOperator;

    self.txtOperator.text = _selectedMobileOperator.operatorDescription;
    self.lblOperator.hidden = YES;
    self.txtOperator.borderInactiveColor = [UIColor colorWithRed:172.0/255.0  green:185.0/255.0 blue:191.0/255.0 alpha:1.0];

    if (selectedMobileOperator.operatorId.integerValue == 3) {
        _myOperatorType = LandlineViewControllerOperatorType3;
    }
    else if (selectedMobileOperator.operatorId.integerValue == 7){
      _myOperatorType = LandlineViewControllerOperatorType2;
    }
    else{

        _myOperatorType = LandlineViewControllerOperatorType1;
    }

     [self performSelector:@selector(configureUIForSelectedOperatorType) withObject:nil afterDelay:0.5f];
}

- (void) configureUIForSelectedOperatorType { // this method will be called once operator is selected

    if (_myOperatorType == LandlineViewControllerOperatorType1) {


        self.rupeeSymble.hidden=NO;
        [self.txtLandlindNumber setHidden:NO];
        [self.txtAmount setHidden:NO];
        [self.txtAccountNumber setHidden:YES];
        [self.txtLLI_LLC setHidden:YES];
        [self.txtSTD setHidden:NO];

         [self allLblHidden];

        self.txtOperator.frameY =40;

        [self.lblOperator setFrameX:self.txtOperator.frameX];
        [self.lblOperator setFrameY:(self.txtOperator.frameY + self.txtOperator.frameHeight + 1)];

        [self.txtSTD setFrameX:self.txtOperator.frameX];
        [self.txtSTD setFrameY:(self.lblOperator.frameY + self.lblOperator.frameHeight + 10)];
        self.txtSTD.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"stdCode"] objectForKey:@"label"];
        self.txtSTD.text=@"";

        [self.lblSTD setFrameX:self.txtSTD.frameX];
        [self.lblSTD setFrameY:(self.txtSTD.frameY + self.txtSTD.frameHeight + 1)];
         self.lblSTD.text=[[_selectedMobileOperator.parameterList objectForKey:@"stdCode"] objectForKey:@"errorMsg"];

        [self.txtLandlindNumber setFrameX:(self.txtSTD.frameX + self.txtSTD.frameWidth+ 10)];
        [self.txtLandlindNumber setFrameY:self.txtSTD.frameY];
         self.txtLandlindNumber.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"utilityCreditDestination"] objectForKey:@"label"];

        [self.lblLandlindNumber setFrameX:self.txtLandlindNumber.frameX];
        [self.lblLandlindNumber setFrameY:self.lblSTD.frameY];
         self.lblLandlindNumber.text=[[_selectedMobileOperator.parameterList objectForKey:@"utilityCreditDestination"] objectForKey:@"errorMsg"];

        [self.txtAmount setFrameX:self.txtSTD.frameX];
        [self.txtAmount setFrameY:(self.lblSTD.frameY + self.lblSTD.frameHeight+10)];
        self.txtAmount.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"utilityTransactionAmount"] objectForKey:@"label"];


        [self.lblAmount setFrameX:self.txtAmount.frameX];
        [self.lblAmount setFrameY:(self.txtAmount.frameY + self.txtSTD.frameHeight + 1)];
        self.lblAmount.text=[[_selectedMobileOperator.parameterList objectForKey:@"utilityTransactionAmount"] objectForKey:@"errorMsg"];

        [self.rupeeSymble setFrameX:self.txtAmount.frameX];
        [self.rupeeSymble setFrameY:self.lblAmount.frameY - 25];
        [self.rupeeSymble bringSubviewToFront:self.txtAmount];

    }
    else if (_myOperatorType == LandlineViewControllerOperatorType2) {

        self.rupeeSymble.hidden=NO;
        [self.txtLandlindNumber setHidden:NO];
        [self.txtAmount setHidden:NO];
        [self.txtAccountNumber setHidden:NO];
        [self.txtSTD setHidden:NO];
        [self.txtLLI_LLC setHidden:YES];

        [self allLblHidden];

        self.txtOperator.frameY =20;

        [self.lblOperator setFrameX:self.txtOperator.frameX];
        [self.lblOperator setFrameY:(self.txtOperator.frameY + self.txtOperator.frameHeight + 1)];

        [self.txtSTD setFrameX:self.txtOperator.frameX];
        [self.txtSTD setFrameY:(self.lblOperator.frameY + self.lblOperator.frameHeight + 10)];

        self.txtSTD.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"stdCode"] objectForKey:@"label"];

        [self.lblSTD setFrameX:self.txtOperator.frameX];
        [self.lblSTD setFrameY:(self.txtSTD.frameY + self.txtSTD.frameHeight + 1)];
        self.lblSTD.text=[[_selectedMobileOperator.parameterList objectForKey:@"stdCode"] objectForKey:@"errorMsg"];
         self.txtSTD.text=@"011";

        [self.txtLandlindNumber setFrameX:(self.txtSTD.frameX + self.txtSTD.frameWidth+ 10)];
        [self.txtLandlindNumber setFrameY:self.txtSTD.frameY];
        self.txtLandlindNumber.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"utilityCreditDestination"] objectForKey:@"label"];

        [self.lblLandlindNumber setFrameX:self.txtLandlindNumber.frameX];
        [self.lblLandlindNumber setFrameY:self.lblSTD.frameY];
        self.lblLandlindNumber.text=[[_selectedMobileOperator.parameterList objectForKey:@"utilityCreditDestination"] objectForKey:@"errorMsg"];

        [self.txtAccountNumber setFrameX:self.txtOperator.frameX];
        [self.txtAccountNumber setFrameY:(self.lblLandlindNumber.frameY + self.lblLandlindNumber.frameHeight+ 10)];
        self.txtAccountNumber.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"billAccountNumber"] objectForKey:@"label"];

        [self.lblAccountNumber setFrameX:self.txtAccountNumber.frameX];
        [self.lblAccountNumber setFrameY:(self.txtAccountNumber.frameY + self.txtAccountNumber.frameHeight + 1)];
         self.lblAccountNumber.text=[[_selectedMobileOperator.parameterList objectForKey:@"billAccountNumber"] objectForKey:@"errorMsg"];

        [self.txtAmount setFrameX:self.txtAccountNumber.frameX];
        [self.txtAmount setFrameY:(self.lblAccountNumber.frameY + self.lblAccountNumber.frameHeight+ 10)];
        self.txtAmount.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"utilityTransactionAmount"] objectForKey:@"label"];


        [self.lblAmount setFrameX:self.txtAmount.frameX];
        [self.lblAmount setFrameY:(self.txtAmount.frameY + self.txtAmount.frameHeight + 1)];
        self.lblAmount.text=[[_selectedMobileOperator.parameterList objectForKey:@"utilityTransactionAmount"] objectForKey:@"errorMsg"];

        [self.rupeeSymble setFrameX:self.txtAmount.frameX];
        [self.rupeeSymble setFrameY:self.lblAmount.frameY - 25];
        [self.rupeeSymble bringSubviewToFront:self.txtAmount];


    }
    else if (_myOperatorType == LandlineViewControllerOperatorType3) {

        self.rupeeSymble.hidden=NO;
        [self.txtLandlindNumber setHidden:NO];
        [self.txtAmount setHidden:NO];
        [self.txtAccountNumber setHidden:NO];
        [self.txtLLI_LLC setHidden:NO];
        [self.txtSTD setHidden:NO];

        [self allLblHidden];

        self.txtOperator.frameY =5;

        [self.lblOperator setFrameX:self.txtOperator.frameX];
        [self.lblOperator setFrameY:(self.txtOperator.frameY + self.txtOperator.frameHeight + 1)];

        [self.txtSTD setFrameX:self.txtOperator.frameX];
        [self.txtSTD setFrameY:(self.lblOperator.frameY + self.lblOperator.frameHeight + 3)];
        self.txtSTD.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"stdCode"] objectForKey:@"label"];
        self.txtSTD.text=@"";

        [self.lblSTD setFrameX:self.txtOperator.frameX];
        [self.lblSTD setFrameY:(self.txtSTD.frameY + self.txtSTD.frameHeight + 1)];
        self.lblSTD.text=[[_selectedMobileOperator.parameterList objectForKey:@"stdCode"] objectForKey:@"errorMsg"];

        [self.txtLandlindNumber setFrameX:(self.txtSTD.frameX + self.txtSTD.frameWidth+ 10)];
        [self.txtLandlindNumber setFrameY:self.txtSTD.frameY];
        self.txtLandlindNumber.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"utilityCreditDestination"] objectForKey:@"label"];

        [self.lblLandlindNumber setFrameX:self.txtLandlindNumber.frameX];
        [self.lblLandlindNumber setFrameY:self.lblSTD.frameY];
        self.lblLandlindNumber.text=[[_selectedMobileOperator.parameterList objectForKey:@"utilityCreditDestination"] objectForKey:@"errorMsg"];

        [self.txtAccountNumber setFrameX:self.txtSTD.frameX];
        [self.txtAccountNumber setFrameY:(self.lblSTD.frameY + self.lblSTD.frameHeight+ 3)];
        self.txtAccountNumber.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"billAccountNumber"] objectForKey:@"label"];

        [self.lblAccountNumber setFrameX:self.txtAccountNumber.frameX];
        [self.lblAccountNumber setFrameY:(self.txtAccountNumber.frameY + self.txtAccountNumber.frameHeight + 1)];
        self.lblAccountNumber.text=[[_selectedMobileOperator.parameterList objectForKey:@"billAccountNumber"] objectForKey:@"errorMsg"];


        [self.txtLLI_LLC setFrameX:self.txtAccountNumber.frameX];
        [self.txtLLI_LLC setFrameY:(self.lblAccountNumber.frameY + self.lblAccountNumber.frameHeight+ 3)];
         self.txtLLI_LLC.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"lli_LLC"] objectForKey:@"label"];

        [self.lblLLI_LLC setFrameX:self.txtLLI_LLC.frameX];
        [self.lblLLI_LLC setFrameY:(self.txtLLI_LLC.frameY + self.txtLLI_LLC.frameHeight + 1)];
        self.lblLLI_LLC.text=[[_selectedMobileOperator.parameterList objectForKey:@"lli_LLC"] objectForKey:@"errorMsg"];

        [self.txtAmount setFrameX:self.txtLLI_LLC.frameX];
        [self.txtAmount setFrameY:(self.lblLLI_LLC.frameY + self.lblLLI_LLC.frameHeight+ 3)];
        self.txtAmount.placeholder=[[_selectedMobileOperator.parameterList objectForKey:@"utilityTransactionAmount"] objectForKey:@"label"];

        [self.lblAmount setFrameX:self.txtAmount.frameX];
        [self.lblAmount setFrameY:(self.txtAmount.frameY + self.txtAmount.frameHeight + 1)];
        self.lblAmount.text=[[_selectedMobileOperator.parameterList objectForKey:@"utilityTransactionAmount"] objectForKey:@"errorMsg"];

        [self.rupeeSymble setFrameX:self.txtAmount.frameX];
        [self.rupeeSymble setFrameY:self.lblAmount.frameY - 25];
        [self.rupeeSymble bringSubviewToFront:self.txtAmount];

    }
    else {

        [self.txtLandlindNumber setHidden:YES];
        [self.txtAmount setHidden:YES];
        [self.txtAccountNumber setHidden:YES];
        [self.txtLLI_LLC setHidden:YES];
        [self.txtSTD setHidden:YES];

        [self.lblSTD setHidden:YES];
        [self.lblLandlindNumber setHidden:YES];
        [self.lblAmount setHidden:YES];
        [self.lblAccountNumber setHidden:YES];
        [self.lblLLI_LLC setHidden:YES];
        [self.lblOperator setHidden:YES];


        [self.txtOperator setCenter:CGPointMake(CGRectGetMidX(self.view.bounds),
                                                CGRectGetMidY(self.view.bounds))]; // this will take txtOperator at the center of screen


        self.txtOperator.frameY=40;

        NSLog(@"%@", NSStringFromCGRect(self.txtOperator.frame));

//        [self.lblOperator setFrameX:self.txtOperator.frameX];
//        [self.lblOperator setFrameY:(self.txtOperator.frameY + self.txtOperator.frameHeight + 5)];
    }
}

**`strong text`**

0 个答案:

没有答案