2016-02-29 70 views
0

我想知道是否可以裝載/本模態與像圖像「自由形式」尺寸以下負載視圖控制器具有特定大小

enter image description here

一個UIViewController欲在頂部加載紅色(allways可見),並與下面的ViewController(藍色)進行交互。

編輯:我想要的是顯示和隱藏從應用程序代表一個小視圖控制器來控制我的應用程序中的音樂。 我正在嘗試用自定義UIViewController作爲文件所有者的xib文件(請參閱下圖)。廈門國際銀行將被正確顯示我想要的方式,但與之相關的UIViewController中,ID不加載,我不知道爲什麼...

enter image description here

,所以我認爲這樣做有UIViewController的自由形成的,但我不是做它,我不知道至極是最好的方式

EDIT2:

隨着廈門國際銀行文件的方式,我做了下一個:

在AppDelegate中我有一個函數showPlayer這是與本地調用通知顯示廈門國際銀行

-(void)showPlayer:(int)tag andObjetoCancion:(NSArray *)objetoCancion 
{ 

ZocaloPlayerViewController *vc = [[ZocaloPlayerViewController alloc] initWithNibName:@"ZocaloPlayerView" bundle:nil]; 
[vc setObjectoCancion:[objetoCancion mutableCopy]]; 

if (globals.isPlaying) { 
    [vc setCambiar:YES]; 
}else{ 
    [vc setCambiar:NO]; 
} 

//here playerView is a UIView initiated in didFinishLaunchingWithOptions 
if (playerView == nil) { 
    playerView = [[UIView alloc] initWithFrame:CGRectMake(0, self.window.frame.size.height, self.window.frame.size.width, altoPlayer)]; 
} 

//keyWindow is UIWindow 
//NSLog(@"Abro view %ld", (long)viewPlayer.tag); 
keyWindow = [[[UIApplication sharedApplication] delegate] window]; 
[keyWindow addSubview:playerView]; 
[keyWindow bringSubviewToFront:playerView]; 


NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"ZocaloPlayerView" owner:vc options:nil]; 
mainView = [subviewArray objectAtIndex:0]; 
mainView.translatesAutoresizingMaskIntoConstraints = NO; //This part hung me up 


[playerView addSubview:mainView]; 

//needed to make smaller for iPhone 4 dev here, so >=200 instead of 748 
[playerView addConstraints:[NSLayoutConstraint 
          constraintsWithVisualFormat:@"V:|-0-[mainView]-0-|" 
          options:NSLayoutFormatDirectionLeadingToTrailing 
          metrics:nil 
          views:NSDictionaryOfVariableBindings(mainView)]]; 

[playerView addConstraints:[NSLayoutConstraint 
          constraintsWithVisualFormat:@"H:|-0-[mainView]-0-|" 
          options:NSLayoutFormatDirectionLeadingToTrailing 
          metrics:nil 
          views:NSDictionaryOfVariableBindings(mainView)]]; 

[UIView animateWithDuration:0.3 animations:^{ 
    playerView.center = CGPointMake(self.window.frame.size.width/2, self.window.frame.size.height - mitadAltoPlayer); 
    [self.window layoutIfNeeded]; 
}]; 

} 

ZocaloPlayerViewController * VC被實例化,但裏面的viewDidLoad中的功能不被稱爲....這是我的第一個問題......

隨着免費的UIViewController方式形成我不知道該怎麼辦呢?

+0

因此你說紅色應該顯示爲導航欄? –

+0

Teja Nandamuri。不,我想從窗口底部顯示它。比方說,像一個底部條... – Quetool

+1

是的,你可以訪問任何視圖控制器視圖,並顯示在另一個視圖。或嘗試使用容器視圖。 –

回答

0

好吧,我解決我的問題與這個職位Loaded nib but the view outlet was not set - new to InterfaceBuilder (我錯過了UIView出口)

我在showPlayer樂趣改變了我的代碼ction to this:

-(void)mostrarPlayer:(int)tag andObjetoCancion:(NSArray *)objetoCancion 
{ 

ZocaloPlayerViewController *vc = [[ZocaloPlayerViewController alloc] initWithNibName:@"ZocaloPlayerView" bundle:nil]; 
[vc setObjectoCancion:[objetoCancion mutableCopy]]; 

if (globals.isPlaying) { 
    [vc setCambiar:YES]; 
}else{ 
    [vc setCambiar:NO]; 
} 


if (playerView == nil) { 
    playerView = [[UIView alloc] initWithFrame:CGRectMake(0, self.window.frame.size.height, self.window.frame.size.width, altoPlayer)]; 
} 

//NSLog(@"Abro view %ld", (long)viewPlayer.tag); 
keyWindow = [[[UIApplication sharedApplication] delegate] window]; 
[keyWindow addSubview:playerView]; 
[keyWindow bringSubviewToFront:playerView]; 

[playerView addSubview:vc.view]; 

[UIView animateWithDuration:0.3 animations:^{ 
    playerView.center = CGPointMake(self.window.frame.size.width/2, self.window.frame.size.height - mitadAltoPlayer); 
    [self.window layoutIfNeeded]; 
}]; 

} 
相關問題