0

ボタンがタップされたときにサブビューとして別のものがロードされる(UIViewControllerメインVC)があります。実際には、メイン ビュー コントローラーのサブビューとしてマップ ビューを読み込みます。そのためには、座標をサブビュー (マップ ビュー) に渡して を作成し、内にロードする必要があります。UIViewMainViewControllerMainViewControllerannotationMainViewController

MainViewControllerのメソッドでは、サブビューを正しくロードします。

-(IBAction)showUserLocation{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"UserCurrentLocationView" owner:self options:nil];
    UIView *currentLocationView = [nib objectAtIndex:0];

    currentLocationView.frame = CGRectMake(8, 10, currentLocationView.frame.size.width, currentLocationView.frame.size.height);

    [thirdPortion addSubview:currentLocationView]; // thirdPortion is a View Outlet in the Main VC wh
}

ここでは、座標 (緯度/経度) をUserCurrentLocationViewのクラスに渡して、マップを準備できるようにし、メソッドがボタンによって呼び出されたMainViewControllerときにポイントされたマップを確認できるようにします。showUserLocation

UIViewから(サブビュー)にとどまるプロパティの値を設定する方法は何ですかMainViewController

前もって感謝します!

4

1 に答える 1

0

UIView(私はそれを呼びます)をサブクラス化し、YourViewとの2つのプロパティを追加する必要がlongありlatます。次に、それをUserCurrentLocationViewという名前の.xibファイルのクラスとして配置します。

次に、以下を実行して変数を設定します。

-(IBAction)showUserLocation{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"UserCurrentLocationView" owner:self options:nil];
    YourView *currentLocationView = (YourView *)[nib objectAtIndex:0];

    currentLocationView.lon = self.fooValue;
    currentLocationView.lat = self.fooValue2;

    currentLocationView.frame = CGRectMake(8, 10, currentLocationView.frame.size.width, currentLocationView.frame.size.height);

    [thirdPortion addSubview:currentLocationView]; // thirdPortion is a View Outlet in the Main VC wh
}
于 2013-03-14T10:38:15.080 に答える