UIView更改导航视图内部

时间:2012-05-28 22:32:19

标签: iphone ios uiviewcontroller uinavigationcontroller uinavigationbar

我正在使用基本导航模板,该模板具有保存导航栏等的主视图,最后在构建应用程序时在其中加载视图。

我想知道如何制作它,以便用户可以在此主视图中导航多个视图,而无需像在更改导航器应用程序内的视图时那样向导航堆栈添加任何内容。

我计划转换这些视图的方式是轻扫手势..

任何帮助都会非常感激,希望我已经很好地解释了我的问题,因为它很难解释。

1 个答案:

答案 0 :(得分:1)

我会使用带分页的UIScrollView来解决这个问题。

但是如果这对您不起作用,请尝试以下方法:

- (void) swipedScreen:(id) sender {
    //I'll leave getNewView to you to implement based on how you want to get the new view
    UIView *newView = [self getNewView];
    self.view = newView;
}

- (void) setupSwipeGestureRecognizer {
    UISwipeGestureRecognizer *swipeGesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedScreen:)] autorelease];
    swipeGesture.direction = (UISwipeGestureRecognizerDirectionUp|UISwipeGestureRecognizerDirectionDown);
    [window addGestureRecognizer:swipeGesture];
}

- (void) viewDidLoad {
    [self setupSwipeGestureRecognizer];
}

不要忘记在适当的时候删除手势识别器。