2013-05-09 47 views
0

我有一個MapBox庫的地圖。 現在我這樣設置背景:UIView顯示它的25%

UIView *background = [[[NSBundle mainBundle] loadNibNamed:@"IGBackgroundView" owner:self options:nil] objectAtIndex:0]; 
    [_mapView setBackgroundView:myView]; 

注意setBackgroundView:AKS對於一個UIView *

這個偉大的工程,它顯示正確。 我想要的是讓背景更花哨。 我想動畫它使用:

animationContainer.animationImages = imagesArray; 
animationContainer.animationDuration = 0.5f; 
[animationContainer startAnimating]; 

那裏我想打一個控制器,以便筆尖可以有文件所有者,有我可以添加代碼,以保持整潔,乾淨。

現在我有:

#import <UIKit/UIKit.h> 

@interface IGBackgroundViewController : UIView 

@property (nonatomic, strong) UIView *view; 

@end 

#import "IGBackgroundViewController.h" 

@implementation IGBackgroundViewController 

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     // Initialization code 

     _view = [[[NSBundle mainBundle] loadNibNamed:@"IGBackgroundView" owner:self options:nil] objectAtIndex:0]; 

     [self addSubview:_view]; 
    } 
    return self; 
} 


@end 

並設置我使用的背景:

IGBackgroundViewController *background = [[IGBackgroundViewController alloc] init]; 

    [_mapView setBackgroundView:background]; 

它的工作原理,但它顯示像總數的25%: nib and result

任何人都知道爲什麼會發生這種情況?

P.s.我對iOS開發很陌生。

回答

1

注意Autosize!

您可能在Interface Builder中設置了錯誤,當您運行應用程序時,視圖會處於不同的位置。

enter image description here

希望這有助於。

+0

在尺寸檢查器中,我可以找到「顯示框架矩形」原點,x,y,寬度和高度。但是自動化不在那裏。 – clankill3r 2013-05-09 10:35:32