0

MapBox ライブラリを使用したマップがあります。今、私はこのように背景を設定します:

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

注 setBackgroundView: UIView* の aks

これはうまく機能し、正しく表示されます。私が望むのは、背景をもう少し派手にすることです。私はそれを使ってアニメーション化したい:

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

nib がファイル所有者を持つことができるようにコントローラーを作成したいので、そこにコードを追加して物事をきれいに保つことができます。

今私が持っています:

#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% のように表示されます。 ペン先と結果

なぜこれが起こるのか誰にも分かりますか?

PS私はiOS開発にかなり慣れていません。

4

1 に答える 1

1

オートサイズに注意!

おそらく、Interface Builder で何か間違った設定をしており、アプリを実行すると、ビューが別の位置に移動します。

ここに画像の説明を入力

この助けを願っています。

于 2013-05-09T10:29:25.210 に答える