gpt4 book ai didi

ios - 如何解决ios中个人热点开启时 View 中断的问题?

转载 作者:行者123 更新时间:2023-12-01 19:53:57 25 4
gpt4 key购买 nike

我以编程方式为 UITabBarController 创建 View .

ViewController.m

    @interface ViewController ()
{
UITabBarController *tabBarController;
MainViewController *mainView;
GroupViewController *grpView;
}

-(id)init
{
self=[super init];

[self initControl];
return self;
}


-(void)initControl
{

}

- (void)viewDidLoad {
[super viewDidLoad];

NSLog(@"ViewController - viewDidLoad");
self.mainView=[[MainViewController alloc] init];
self.grpView=[[GroupViewController alloc] initWithNibName:@"GroupViewController" bundle:[NSBundle mainBundle]];
self.meView=[[MeViewController alloc] initWithNibName:@"MeViewController" bundle:[NSBundle mainBundle]];



UITabBarItem *tempItem=[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Device", @"Device") image:[[UIImage imageNamed:@"device1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] tag:1];
tempItem.selectedImage=[UIImage imageNamed:@"device"];
mainView.tabBarItem=tempItem;
tempItem.imageInsets = UIEdgeInsetsMake(0.0, 0, -0.0, 0);


tempItem=[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Group", @"Group") image:[[UIImage imageNamed:@"group1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] tag:2];
tempItem.selectedImage=[UIImage imageNamed:@"group1"];
grpView.tabBarItem=tempItem;
tempItem.imageInsets = UIEdgeInsetsMake(0.0, 0, -0.0, 0);

self.tabBarController= [[UITabBarController alloc] init];
NSMutableArray *controllers=[[NSMutableArray alloc] initWithCapacity:2];

[controllers addObject:self.mainView];
[controllers addObject:self.grpView];

self.tabBarController.viewControllers =controllers;
[self.view addSubview:self.tabBarController.view];
self.tabBarController.delegate=self;
}

当个人热点关闭时,它工作正常。

enter image description here

当我打开热点并且有人连接到 iPhone 时,然后打开应用程序。 view像下面的屏幕截图 当个人热点开启 .

enter image description here

个人热点开启时如何解决?
提前致谢。

最佳答案

检查这个

为状态栏添加观察者改变了长度:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(StatusbarspaceHide:) name:UIApplicationWillEnterForegroundNotification object:nil];

状态栏更改时的操作:
-(void)StatusbarspaceHide:(NSNotificationCenter *)notification{
[UIView animateWithDuration:0.35 animations:^{
// CGRect windowFrame = ((UINavigationController *)((UITabBarController *)self.window.rootViewController).viewControllers[0]).view.frame;
CGRect windowFrame = self.view.frame;

if (self.view.frame.origin.y > 20) {
windowFrame.origin.y = self.view.frame.size.height - 20 ;// old status bar frame is 20
}
self.view.frame = windowFrame;
}];
}

关于ios - 如何解决ios中个人热点开启时 View 中断的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43910465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com