1

我创建了一个地图视图,其中包含页面卷曲功能。mapview 有一个工具栏,带有一个页面卷曲按钮。单击按钮时,地图视图页面会卷曲。这是代码。

-(IBAction) onPageCurl:(id)sender{

pageCurlViewController = [[MyMapViewPageCurlViewController alloc] initWithNibName:@"MyMapViewPageCurlViewController" bundle:nil];
[pageCurlViewController.navigationController.toolbar setHidden:NO];
[pageCurlViewController setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[pageCurlViewController setToolbarItems:toolbarItems];
[[self navigationController] presentModalViewController:pageCurlViewController animated:YES];

[pageCurlViewController getMapView:&mapView];
[pageCurlViewController release];
}

随着地图视图页面的卷曲,我在它下面有一个新的视图控制器。新的视图控制器有一个带有 3 个段的分段控件。

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

[self.navigationController.toolbar setHidden:NO];
[directionSearchSegmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
directionSearchSegmentedControl.selectedSegmentIndex = selectedIndex;
UIBarButtonItem *directionSearchSegmentedControlButton = [[[UIBarButtonItem alloc] initWithCustomView:directionSearchSegmentedControl] autorelease];

NSArray *toolbarItems = [NSArray arrayWithObjects: navigatorButton , flexibleSpace, directionSearchSegmentedControlButton, flexibleSpace, pageCurlButton, nil];
[self setToolbarItems:toolbarItems];
[self.navigationController.toolbar setHidden:NO];


}

单击分段控制器中的每个段时,我有地图的标准/卫星/混合视图。

- (void)segmentAction:(id)sender
{
[self dismissModalViewControllerAnimated:YES];
    if([sender selectedSegmentIndex] == 0){
        selectedIndex = 0;
        pageCurlMapView.mapType = MKMapTypeStandard;
    }
    if([sender selectedSegmentIndex] == 1){
        selectedIndex = 1;
        pageCurlMapView.mapType = MKMapTypeSatellite;
    }
    if([sender selectedSegmentIndex] == 2){
        selectedIndex = 2;
        pageCurlMapView.mapType = MKMapTypeHybrid;
    }
    if([sender selectedSegmentIndex] == 2){

    }
directionSearchSegmentedControl.momentary = YES;
selectedIndex = directionSearchSegmentedControl.selectedSegmentIndex;
}

页面卷曲功能工作正常。随着页面卷曲,如前所述,我在新视图中有一个分段控件。但是分段控件在 IOS 6 中不能正常工作。我已经调试和检查过了。单击段时,控件不进入事件方法。它在以前的 IOS 版本中仍然可以正常工作,但在 IOS 6 中却不行。无法弄清楚,出了什么问题。需要帮助。

4

2 回答 2

0

如果您在应用程序启动时查看 Xcode 控制台,您是否看到如下消息:

应用程序在应用程序启动结束时应该有一个根视图控制器

如果是这样,那么您的问题可能是由于需要为 iOS 6 设置根视图控制器的方式发生了变化。

有关如何解决问题的信息,请参见此处。

于 2012-10-10T10:29:03.347 回答
0

抱歉,如果这有点晚了,但我一直在我的应用程序中做类似的事情。老实说,我只是使用了一个简单的切换方法来更改地图类型。代码如下。

- (IBAction)toggle:(id)sender {

switch ([sender selectedSegmentIndex]) {
    case 0:
    {
        [self.mapView setMapType:MKMapTypeStandard];
    }break;
    case 1:
    {
        [self.mapView setMapType:MKMapTypeHybrid];
    }break;
    case 2:
    {
        [self.mapView setMapType:MKMapTypeSatellite];
    }break;
  }

}

现在我还没有尝试将它与多个视图控制器一起使用,所以这可能只适用于一个视图控制器。我刚开始在 iOS 上编程,所以请耐心等待。我将尝试将页面卷曲效果添加到我的应用程序中,但到目前为止我只有一个地图视图和一个按钮,当它被按下时,它会放大到用户的位置和用户可以更改地图类型..

PS这是一个分段控件,设置为名为“切换”的值更改操作,如果有帮助的话......

于 2013-02-27T08:31:03.610 回答