首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何解决ios中个人热点打开时视图中断的问题?

如何解决ios中个人热点打开时视图中断的问题?
EN

Stack Overflow用户
提问于 2017-05-11 08:37:30
回答 1查看 487关注 0票数 1

我以编程方式为UITabBarController创建视图。

ViewController.m

代码语言:javascript
运行
复制
    @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;
    }

当个人热点关闭时,它会很好地工作。

当我打开热点,有人连接到iPhone,而不是打开应用程序。当个人热点在view上时,就像下面的屏幕截图一样离开了屏幕。

当个人热点打开时,如何解决这个问题?提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2017-05-11 09:07:21

检查此

添加状态栏的观察者更改了长度:

代码语言:javascript
运行
复制
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(StatusbarspaceHide:) name:UIApplicationWillEnterForegroundNotification object:nil];

当状态栏更改时操作:

代码语言:javascript
运行
复制
-(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;
    }];
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43910465

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档