Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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
iOS 11.2自定义导航栏无限循环_Ios_Objective C_Uinavigationcontroller_Uinavigationbar_Ios11.2 - Fatal编程技术网

iOS 11.2自定义导航栏无限循环

iOS 11.2自定义导航栏无限循环,ios,objective-c,uinavigationcontroller,uinavigationbar,ios11.2,Ios,Objective C,Uinavigationcontroller,Uinavigationbar,Ios11.2,由于IOS 11.2的发布,我的应用程序在推一个导航控制器具有自定义导航栏高度的视图控制器时遇到了无限循环。有人找到解决这个问题的办法了吗?谢谢 -(void)layoutSubviews{ [super layoutSubviews]; float height = 42.5; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { height = 48; } imageView

由于IOS 11.2的发布,我的应用程序在推一个导航控制器具有自定义导航栏高度的视图控制器时遇到了无限循环。有人找到解决这个问题的办法了吗?谢谢

-(void)layoutSubviews{
   [super layoutSubviews];
   float height = 42.5;

   if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
       height = 48;

   }

   imageView.frame = CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, height);
   if(UI_USER_INTERFACE_IDIOM() ==UIUserInterfaceIdiomPad){

       if(@available(iOS 11.0,*)){
           self.frame =CGRectMake(0, 20,[[UIScreen mainScreen]bounds].size.width, 55); // this line provoke the infinite loop

           for(UIView *aView in self.subviews){
               if([NSStringFromClass([aView class]) isEqualToString: @"_UINavigationBarContentView"]){
                   aView.frame = CGRectMake(0, 10, aView.frame.size.width, aView.frame.size.height);
               }
               if([NSStringFromClass([aView class]) isEqualToString: @"_UIBarBackground"]){
                   aView.frame = CGRectMake(0, 0, aView.frame.size.width, self.frame.size.height );
               }

           }

       }
   }
}

我也有同样的问题。 我解决了这个问题

frame.size.height = customHeight
从LayoutSubView,然后添加此

override var frame: CGRect {

    get {

        return CGRect(x: 0, y: 0, width: super.frame.width, height: customHeight)

    }
    set (value) {
        super.frame = value

    }

}
到我的UINavigationBar子类。
我将所有其他代码保留在LayoutSubview中,与以前一样。nb

您在代码中从何处发现无限循环?请提及代码行.self.frame=CGRectMake0,20,[[UIScreen mainScreen]bounds].size.width,55;这条线激起了无限的循环。这是UINavigationBar的子类,您是如何添加自定义导航栏的?这修复了无限循环,但导航栏框架不会更改。