【发布时间】:2011-11-20 12:58:15
【问题描述】:
我有一个带有 3 个按钮布局的 UISegmentedControl,我用它来控制我拥有的 3 个视图布局 我能够检测到每个按钮上的点击,但是如何为每个视图加载和显示我想要的视图
它们必须加载 1 次并在点击 UISegmentedView 的 ID 时显示
这是一个有多个页面的编辑保存情况..
【问题讨论】:
标签: iphone uiview uiviewcontroller uisegmentedcontrol tap
我有一个带有 3 个按钮布局的 UISegmentedControl,我用它来控制我拥有的 3 个视图布局 我能够检测到每个按钮上的点击,但是如何为每个视图加载和显示我想要的视图
它们必须加载 1 次并在点击 UISegmentedView 的 ID 时显示
这是一个有多个页面的编辑保存情况..
【问题讨论】:
标签: iphone uiview uiviewcontroller uisegmentedcontrol tap
使用 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];
}
}
【讨论】: