2016-02-29 22 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]; 
}]; 

} 
相关问题