ViewController向上移动 - iOS

时间:2013-06-27 17:59:40

标签: ios

以下代码是向上滚动查看。但是,它并没有改变我的viewcontoller。我已经调试了代码并且它击中了每一行代码,但是我的视图控制器。没有升级

//DownViewController.m

-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField
{
    if (textField == self.hoursTextField) {
        [textField resignFirstResponder];
        taggy=self.hoursTextField.tag;
    }
    if (textField ==self.codeTextField) {
        [textField resignFirstResponder];
        taggy=self.codeTextField.tag;

    }
    return YES;

}
    - (void)keyboardDidShow:(NSNotification *)notification
    {
        //Assign new frame to your view
        sensorViewController =[[SensorsViewController alloc]initWithNibName:@"SensorsViewController" bundle:[NSBundle mainBundle]];
        [sensorViewController setTag:taggy];


    }


//SensorsViewController.m

    -(void)setTag: (int)tag
    {
        if(tag==1)
        {
            a=-80;
            [self.view setFrame:CGRectMake(0,a,1030,768)];
        }
        if(tag==2)
        {
             a=-260;
            [self.view setFrame:CGRectMake(0,a,1030,768)];
        }

    }

2 个答案:

答案 0 :(得分:0)

setTag的{​​{1}}内转移viewDidLoad方法的调用。

答案 1 :(得分:0)

每次键盘显示时,您都会为sensorViewController分配一个新值。您刚刚分配的实例不在屏幕上,因此当然屏幕上的实例不会受到影响。您应该保留对已经在屏幕上的视图控制器的引用,如果您正在使用故事板或nib文件,则可以使用IBOutlet。