Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 使用控制器控制其他控制器时的视图大小问题_Iphone_Ios_Uiviewcontroller_Rotation_Uisegmentedcontrol - Fatal编程技术网

Iphone 使用控制器控制其他控制器时的视图大小问题

Iphone 使用控制器控制其他控制器时的视图大小问题,iphone,ios,uiviewcontroller,rotation,uisegmentedcontrol,Iphone,Ios,Uiviewcontroller,Rotation,Uisegmentedcontrol,我正在开发一个基于UISegmentControl切换视图的ViewController。我看了这个后在网上找到了一个 主视图控制器是一个选项卡视图控制器,然后在其中一个选项卡上有一个包含分段控件的uinavigationcontroller(希望您仍与我在一起)。 我遇到的问题是分段控件中视图的高度。第一个选定视图的大小已正确调整,但线段控件中的所有其他视图都忽略了一个事实,即该视图中有一个选项卡栏,并且这些视图位于选项卡栏下 我尝试添加以下内容,但似乎没有帮助 controller1.vie

我正在开发一个基于UISegmentControl切换视图的ViewController。我看了这个后在网上找到了一个

主视图控制器是一个选项卡视图控制器,然后在其中一个选项卡上有一个包含分段控件的uinavigationcontroller(希望您仍与我在一起)。 我遇到的问题是分段控件中视图的高度。第一个选定视图的大小已正确调整,但线段控件中的所有其他视图都忽略了一个事实,即该视图中有一个选项卡栏,并且这些视图位于选项卡栏下

我尝试添加以下内容,但似乎没有帮助

controller1.view.autoresizesSubviews = YES;
controller1.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

controller2.view.autoresizesSubviews = YES;
controller2.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
有什么想法吗

另一个问题是轮换。如果在分段视图上旋转。当前选定的视图将旋转,如果我更改段,视图将不会旋转为横向视图,并且只占屏幕的一小部分(如下所示)

我在SegmentedViewController中重写了所有与旋转相关的方法,并在它管理的视图数组上循环,并在那里调用了方法。不幸的是,这似乎没有起到作用

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];     

    for (UIViewController * viewController in self.segmentedViewControllers) 
        [viewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{
    [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];    

    for (UIViewController * viewController in self.segmentedViewControllers) 
        [viewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];

}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{
    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];    

    for (UIViewController * viewController in self.segmentedViewControllers) 
        [viewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];    
}

等等。

通过以不同的方式实现解决了此问题,如图所示

通过以不同的方式实现解决了此问题,如图所示