0

我有一个带有 3 个按钮布局的 UISegmentedControl,用于控制我拥有的 3 个视图布局我能够检测到每个按钮上的点击,但是如何加载和显示每个视图所需的视图

它们必须加载 1 次并在点击 UISegmentedView 的 ID 时显示

这是具有多个页面的编辑保存情况..

4

1 回答 1

1

使用 UISegmentedControl 对象的 selectedSegmentIndex 属性。

if (segmentedControl.selectedSegmentIndex == 0) {
    NSLog(@"segment 1");
    if (view1 == NULL) {
        view1 = [[UIViewController alloc] init];
        [self.view addSubview:view1.view];
    }

    else {
        [self.view bringSubviewToFront:view1.view];
    }
}

else {
    NSLog(@"segment 2");
    if (view2 == NULL) {
        view2 = [[UIViewController alloc] init];
        [self.view addSubview:view2.view];
    }

    else {
        [self.view bringSubviewToFront:view2.view];
    }
}
于 2011-09-19T19:46:25.177 回答