简体   繁体   English

具有MapView和TableView的模态视图控制器

[英]Modal View Controller with MapView And TableView

I'm looking to replicate the basic functionality of the Stores finder in the new Starbucks app (MapView with a tableview bellow it) but am unsure as to how I would go about implementing the sliding aspect of presenting the view 我正在寻找在新的星巴克应用程序中复制商店查找器的基本功能(MapView带有表格视图),但不确定如何实现呈现视图的滑动方式

应用范例

The main aspect of the functionality I am trying to replicate is the ability to present the modal and have it dismissible by sliding it down off the screen as I am able to replicate the Map + Table view already 我要复制的功能的主要方面是能够呈现模式并通过将其从屏幕上向下滑动来使其消失的能力,因为我已经能够复制Map + Table视图

https://www.cocoacontrols.com/controls/kipulltoreveal只需创建一个自定义单元,即可使其完全相同。

Well from the Gif you posted, It seems that Starbucks just present the view controller modally which is very easy to do. 从您发布的Gif来看,星巴克似乎只是模态地呈现了视图控制器,这很容易做到。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
YourViewController *yourVC= (YourViewController *)
                        [storyboard instantiateViewControllerWithIdentifier:@"yourView"];
[self presentViewController:yourVC animated:YES completion:nil];

As for dissmissing the view you would need to set ViewController's interactivePopGestureRecognizer delegate to self and then handle its behavior in -gestureRecognizerShouldBegin: 至于关闭视图,您需要将ViewController's InteractivePopGestureRecognizer委托设置为self,然后在-gestureRecognizerShouldBegin中处理其行为

That is, when you want the built-in pop gesture ( – popViewControllerAnimated: ) to fire, you must return YES from this method. 也就是说,当您要触发内置弹出手势( – popViewControllerAnimated:)时 ,必须从此方法返回YES。 The same goes for your custom gestures - you have to figure out which recognizer you are dealing with. 自定义手势也是如此-您必须弄清楚正在处理的识别器。

My thought is this is just a viewcontroller containing 2 basic views: 我的想法是,这只是一个包含2个基本视图的ViewController:

  1. The background view including tabs and your personal info page which is below tabs. 背景视图,包括标签和标签下方的您的个人信息页面。
  2. A table view occupying the whole screen. 占据整个屏幕的表格视图。
    • section 0: header: empty header / no cells 第0节:标头:标头为空/无单元格
    • section 1: header: search bar / 1st cell: mapView trespassing its bounds to cover section header / other cells: locations 第1部分:标题:搜索栏/第一个单元格:mapView越界,以覆盖该部分标题/其他单元格:位置
  3. Whenever you scroll down 'too much' they defined. 每当您“向下滚动”时,它们就会定义。 They do animation to hide the tableview 他们做动画来隐藏桌子
  4. To make it looks like a modal view, they make the map corner rounded. 为了使它看起来像模态视图,他们使地图的角变圆了。

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

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