Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.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 视图';s帧未释放其内存_Ios_Objective C_Iphone_Uitabbarcontroller - Fatal编程技术网

Ios 视图';s帧未释放其内存

Ios 视图';s帧未释放其内存,ios,objective-c,iphone,uitabbarcontroller,Ios,Objective C,Iphone,Uitabbarcontroller,我无法纠正在中国出现的情况 customTabView.view.frame = CGRectMake(0, self.view.frame.size.height-49, self.view.frame.size.width, 49); 其中,每次分配的内存在关闭视图后不释放 好的,情况是,我创建了一个简单的登录屏幕作为rootviewcontroller,然后通过一个按钮(登录按钮)显示一个tabviewcontroller,其中,我在tabviewcontroller上添加了一个视图作为

我无法纠正在中国出现的情况

customTabView.view.frame = CGRectMake(0, self.view.frame.size.height-49, self.view.frame.size.width, 49);
其中,每次分配的内存在关闭视图后不释放

好的,情况是,我创建了一个简单的登录屏幕作为
rootviewcontroller
,然后通过一个按钮(登录按钮)显示一个
tabviewcontroller
,其中,我在tabviewcontroller上添加了一个视图作为子视图,在该子视图上有四个按钮,通过委托我控制tabIndex,一切正常,但当我检查内存泄漏时,上面的view.frame保留内存。 我在贴图片,请看这个

这是我的带有custome tabbar的TabView控制器

任何帮助都是值得的

更新:

这是我的完整代码

从登录页面:

- (IBAction)clickLoginBtnAction:(id)sender {


    tabControler = [self.storyboard instantiateViewControllerWithIdentifier:@"TabBarController"];

    [self presentViewController:tabControler animated:YES completion:nil];

}
从选项卡栏控制器:

#import "TabBarController.h"

@interface TabBarController ()<TabBarIndexProtocol>{

//    CustomTabViewController *customTabView;
}

@property (strong) CustomTabViewController *customTabView;



@end

@implementation TabBarController

@synthesize customTabView;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    customTabView = [self.storyboard instantiateViewControllerWithIdentifier:@"CustomTabViewController"];
    self.tabBar.hidden = YES;
    [self frameCustomTabViewOnTabBar];
    customTabView.tabBarIndexDelegate = self;

}

-(void)viewDidDisappear:(BOOL)animated{

//    customTabView.view.frame = nil;
}

// For Screen Rotation

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
    [coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {

        [self frameCustomTabViewOnTabBar];

    }];
}

-(void)frameCustomTabViewOnTabBar{

    customTabView.view.frame = CGRectMake(0, self.view.frame.size.height-49, self.view.frame.size.width, 49);
    [self.view addSubview:customTabView.view];
}


# pragma mark - TabBarIndexProtocol from CustomTabBarClass

-(void)tabBarIndexSelected :(int)tabNumber{

    NSLog(@"%d",(int)tabNumber);

    [self setSelectedIndex:tabNumber];
}

仅此而已,我误解了:(.

您的问题没有意义。视图框架不能容纳或泄漏内存。它是一个标量值。您发布的代码行与内存泄漏的原因无关。该代码不会显示选项卡视图控制器。请显示如何显示它以及如何关闭它的完整代码。您不应尝试添加类似于bu的子视图t连接到
UITableViewController
UITableViewController
仅管理表视图,不支持其他子视图。这可能是您出现问题的原因,但您需要发布设置视图控制器、向其添加视图并显示视图的代码,以便我们帮助您了解出问题了。@Duncan感谢您的快速响应,但当我运行我的项目时,它的内存开始为31.3MB,现在当我演示TabBarcontroller时,它增加到32 MB以上,这很好,但当我解除TabBarcontroller时,它应该释放内存,但不在这里释放。
#import <UIKit/UIKit.h>

@protocol TabBarIndexProtocol <NSObject>

@required

-(void)tabBarIndexSelected :(int)tabNumber;

@end

@interface CustomTabViewController : UIViewController

@property(weak) id <TabBarIndexProtocol> tabBarIndexDelegate;

@end
#import "CustomTabViewController.h"

@interface CustomTabViewController ()

@end

@implementation CustomTabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (IBAction)tabNumberOne:(id)sender {

    [self.tabBarIndexDelegate tabBarIndexSelected:0];
}

- (IBAction)tabNumberTwo:(id)sender {

    [self.tabBarIndexDelegate tabBarIndexSelected:1];
}


- (IBAction)tabNumberThree:(id)sender {

    [self.tabBarIndexDelegate tabBarIndexSelected:2];
}


- (IBAction)tabNumberFour:(id)sender {

    [self.tabBarIndexDelegate tabBarIndexSelected:3];
}