简体   繁体   English

UIView更改NavigationView内部

[英]UIView Change inside navigationview

I am working off the base navigation template which has a master-view holding the navbar etc and finally loads a view inside it when the app is built. 我正在研究具有导航栏等主视图的基本导航模板,并在构建应用程序时最终将视图加载到其中。

I am wondering how to make it so the user can navigate several views inside this master view without adding anything to the navigation stack like you normally would when changing views inside a navigator app. 我想知道如何做到这一点,以便用户可以在此主视图中导航多个视图,而不会像在导航器应用程序中更改视图时通常那样向导航堆栈添加任何内容。

The way I plan to transition these views will be with a swipe gesture.. 我计划转换这些视图的方式将是滑动手势。

any help would be greatly appreciated, hopefully I have explained my problem well enough as its quite a hard thing to explain. 任何帮助将不胜感激,希望我已经很好地解释了我的问题,因为这很难解释。

I'd go about this using a UIScrollView with pagination. 我将使用带有分页的UIScrollView进行此操作。

But in the case that doesn't work for you, try this: 但是,如果这种方法对您不起作用,请尝试以下操作:

- (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];
}

And don't forget to remove the gesture recognizer wherever you feel appropriate. 而且,不要忘了在您认为合适的地方删除手势识别器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM