【问题标题】:Navigation with UISegmentcontrol iphone使用分段控制 iphone 进行导航
【发布时间】:2010-05-16 00:05:29
【问题描述】:

我在详细视图的导航栏右侧创建了一个向上/向下箭头分段控制按钮。如何使用这些向上/向下箭头更改视图?

【问题讨论】:

    标签: iphone navigationcontroller


    【解决方案1】:
    [mySegmentedControl addTarget:self action:@selector(mySegmentedControlTapped:) forControlEvents:UIControlEventValueChanged];
    ...
    
    - (void) mySegmentedControlTapped:(id)sender {
        NSUInteger selectedOption = mySegmentedControl.selectedSegmentIndex;
        if (selectedOption == upArrowIndex) {
            // swap in "up"-ward view controller
        }
        else if (selectedOption == downArrayIndex) {
            // swap in "down"-ward view controller
        } 
    }
    

    【讨论】:

    • 谢谢亚历克斯,下面成功了。 if (segmentedControl.selectedSegmentIndex == 0) { Week0 *page = [[Week0 alloc] initWithNibName:@"Week0" bundle:nil]; [[self navigationController] pushViewController:page Animation:YES]; page.title = NSLocalizedString(@"第 0 周",@""); [页面发布]; } else if (segmentedControl.selectedSegmentIndex == 1) { Week1 *page = [[Week1 alloc] initWithNibName:@"Week1" bundle:nil]; [[self navigationController] pushViewController:page Animation:YES]; page.title = NSLocalizedString(@"第 1 周",@""); [页面发布]; }
    • 您可能想要弹出现有的视图控制器,否则您会将一大堆视图控制器推送到导航堆栈(您可能想要)。
    猜你喜欢
    • 2017-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-15
    相关资源
    最近更新 更多