다음 코드는 위로 스크롤하는 코드입니다. 그러나 그것은 내 viewcontoller 위로 이동하지 않습니다. 내가 코드를 디버깅하고 코드의 모든 단일 라인,하지만 내보기 컨트롤러 안타.ViewController 위로 이동 - iOS
//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)];
}
}
setTag :가 호출되기 전의 프레임은 무엇입니까? –
잠깐 ... viewController를 인스턴스화 한 다음 프레임이 표시되기 전에 프레임을 설정합니다. 그게 문제 같아. –
어떻게 해결 될까요? 어떻게하면 DownViewController에서 SensorViewController를 시작하지 않고 setTag 메서드에 액세스 할 수 있습니까? – casillas