![enter image description here](https://i.stack.imgur.com/cId2I.png)
У меня есть вид со следующей конфигурацией. при нажатии кнопки соответствующий контейнерный вид должен перейти на главный экран с анимацией. Если я нахожусь в портретном или ландшафтном режиме (только один из них), это работает хорошо, но если я пытаюсь повернуть iphone, это не работает.
- (IBAction)button2Pressed:(UIButton *)button {
if(previousButton != button){
if([previousButton.titleLabel.text isEqualToString:@"1"])
[self viewLoadedIntoContainer:-self.container1.frame.size.width];
else if([previousButton.titleLabel.text isEqualToString:@"3"])
[self viewLoadedIntoContainer:self.container1.frame.size.width];
else
[self viewLoadedIntoContainer:self.container1.frame.size.width*2];
previousButton = button;
[self animateLabel:self.button2Outlet.frame.origin.x];
indexCount=1;
}}
- (IBAction)button1Pressed:(UIButton *)button {
if(previousButton != button){
if([previousButton.titleLabel.text isEqualToString:@"2"])
[self viewLoadedIntoContainer:self.container1.frame.size.width];
else if([previousButton.titleLabel.text isEqualToString:@"3"])
[self viewLoadedIntoContainer:self.container1.frame.size.width*2];
else
[self viewLoadedIntoContainer:self.container1.frame.size.width*3];
previousButton = button;
[self animateLabel:self.button1Outlet.frame.origin.x];
indexCount=0;
}}
- (IBAction)button3Pressed:(UIButton *)button {
if(previousButton != button){
if([previousButton.titleLabel.text isEqualToString:@"1"])
[self viewLoadedIntoContainer:-self.container1.frame.size.width*2];
else if([previousButton.titleLabel.text isEqualToString:@"2"])
[self viewLoadedIntoContainer:-self.container1.frame.size.width];
else
[self viewLoadedIntoContainer:self.container1.frame.size.width];
previousButton = button;
[self animateLabel:self.button3Outlet.frame.origin.x];
indexCount=2;
}}
- (IBAction)button4Pressed:(UIButton *)button {
if(previousButton != button){
if([previousButton.titleLabel.text isEqualToString:@"3"])
[self viewLoadedIntoContainer:-self.container1.frame.size.width];
else if([previousButton.titleLabel.text isEqualToString:@"2"])
[self viewLoadedIntoContainer:-self.container1.frame.size.width*2];
else
[self viewLoadedIntoContainer:-self.container1.frame.size.width*3];
previousButton = button;
[self animateLabel:self.button4Outlet.frame.origin.x];
indexCount=3;
}}
-(void)viewLoadedIntoContainer:(CGFloat)x{
__weak __typeof(self) weakSelf = self;
[UIView animateWithDuration:0.3f animations:^{
weakSelf.container1.layer.position = CGPointMake(weakSelf.container1.layer.position.x+(x), weakSelf.container1.layer.position.y);
weakSelf.container2.layer.position = CGPointMake(weakSelf.container2.layer.position.x+(x), weakSelf.container2.layer.position.y);
weakSelf.container3.layer.position = CGPointMake(weakSelf.container3.layer.position.x+(x), weakSelf.container3.layer.position.y);
weakSelf.container4.layer.position = CGPointMake(weakSelf.container4.layer.position.x+(x), weakSelf.container4.layer.position.y);
//[weakSelf.container1 setFrame:CGRectMake(weakSelf.container1.frame.origin.x+(x), weakSelf.container1.frame.origin.y, weakSelf.container1.frame.size.width, weakSelf.container1.frame.size.height)];
//[weakSelf.container2 setFrame:CGRectMake(weakSelf.container2.frame.origin.x+(x), weakSelf.container2.frame.origin.y, weakSelf.container2.frame.size.width, weakSelf.container2.frame.size.height)];
//[weakSelf.container3 setFrame:CGRectMake(weakSelf.container3.frame.origin.x+(x), weakSelf.container3.frame.origin.y, weakSelf.container3.frame.size.width, weakSelf.container3.frame.size.height)];
//[weakSelf.container4 setFrame:CGRectMake(weakSelf.container4.frame.origin.x+(x), weakSelf.container4.frame.origin.y, weakSelf.container4.frame.size.width, weakSelf.container4.frame.size.height)];
}completion:^(BOOL finished) {
//[weakSelf.container1 layoutIfNeeded];
}];
}
Я использую 4 вида контейнера. Должен ли я использовать 4 вида контейнера, которые имеют одинаковую высоту и ширину и лежат друг на друге. Или я должен использовать 4 контроллера представления, которые связаны с одним представлением контейнера, используя собственный переход?