2つのセグメントを持つUIToolBarの下部にUISegmentedControlを持つビューがあります。表示されたビューはデフォルトで表示1に設定されている必要があります。セグメント2を選択すると、ビュー2などに切り替える必要があります。UISegmentedControlを設定するためのヘルプが必要です
今、セグメント2をクリックするとビュー1が非表示になり、 segmentedControlはどのように表示しますか?ビュー1が非表示になると、コントロールも非表示になります。
合計3つのビューを作成する必要はありますか?ビュー1と2は、セグメント化されたコントロールのみを持つデフォルトビューのサブビューとして表示されますか?
EDIT:
- (void)segmentedControl:(SVSegmentedControl*)segmentedControl didSelectIndex:(NSUInteger)index
{
LogResultsViewController* v1 = [[LogResultsViewController alloc] initWithNibName: @"LogResultsViewController" bundle:nil];
CalendarController* v2 = [[CalendarController alloc] initWithNibName: @"CalendarController" bundle:nil];
if (index == 0)
{
[self.view addSubview: v1.view];
}
else
{
[self.view addSubview: v2.view];
}
}
そして、これは、このビューをロードするために使用するコードです:
- (void)loadView
{
UIBarButtonItem *actionButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(dismissCalendarView)];
self.navigationItem.leftBarButtonItem = actionButton;
[actionButton release];
int statusBarHeight = 20;
CGRect applicationFrame = (CGRect)[[UIScreen mainScreen] applicationFrame];
self.view = [[[UIView alloc] initWithFrame:CGRectMake(0, statusBarHeight, applicationFrame.size.width, applicationFrame.size.height)] autorelease];
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.view.backgroundColor = [UIColor grayColor];
calendar.frame = CGRectMake(0, 0, calendar.frame.size.width, calendar.frame.size.height);
[self.view addSubview:calendar];
[calendar reload];
}
ありがとうございます、私はいくつかの更新されたコードを投稿した質問を確認できますか? –