2017-05-11 3 views
1

UITabBarControllerのプログラムでビューを作成します。個人的なホットスポットがiosでオンになっているときにビューを解決するにはどうすればよいですか?

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; 
    } 

ではそれは個人的なホットスポットがオフのときの作業罰金です。

私はホットスポットをオンにし、誰かがiPhoneに接続し、アプリを開くよりも

enter image description here

viewは、パーソナルホットスポットがの場合、次のスクリーンショットのように画面外です。個人的なホットスポットがオンにされたときに、問題を解決する方法

enter image description here

? ありがとうございます。

答えて

2

チェックステータスバーの長さを変更するために、この

はオブザーバを追加します。ステータスバーが変更

[[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; 
    }]; 
} 
+0

を私が試してみるが、それはしませんでした通知を受け取ります。 – Wun

+0

それは私のために働いています...何が起こったのがブレークポイントでチェックされましたか? –

関連する問題