0

我有以下代码:

MapViewController.h

#import <UIKit/UIKit.h>
#import "PlaceViewController.h"

@interface MapViewController : UIViewController <MKMapViewDelegate> {
    IBOutlet PlaceViewController *placeview;
}

- (IBAction)passPlace:(id)sender;

MapViewController.m

@synthesize placeview;

- (IBAction)passPlace:(id)sender{
    self.placeview = [[[PlaceViewController alloc] initWithNibName:nil bundle:nil] autorelease];
    [self presentViewController:placeview animated:YES completion:nil];
}

PlaceViewController.h

@interface PlaceViewController : UIViewController{

}

- (IBAction)back:(id)sender;

@end

PlaceViewController.m

@implementation PlaceViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    NSLog(@"Change!!!!!");
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

还有故事板:

http://img685.imageshack.us/img685/1233/screengy.png

我不知道我做错了什么,因为当我更改视图时, PlaceViewController 是一个带有蓝色状态栏的黑屏。

任何人都可以帮助我吗?谢谢

4

1 回答 1

0

如果您正在使用情节提要...进入情节提要编辑器并在属性检查器中,设置一个标识符,让我们说“PlaceMap”(在图片“AddPlayer”中)

在此处输入图像描述

更改您的代码:

- (IBAction)passPlace:(id)sender{
    self.placeview = [[[PlaceViewController alloc] initWithNibName:nil bundle:nil] autorelease];
    [self presentViewController:placeview animated:YES completion:nil];
}

- (IBAction)passPlace:(id)sender{
PlaceViewController *newView = [self.storyboard instantiateViewControllerWithIdentifier:@"PlaceMap"];
[self.navigationController pushViewController:newView animated:YES];
}

您可以查看 alos,一个非常好的教程:http ://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1

UPD

那是导航控制器

[自我presentViewController:placeview动画:是完成:无];

如果你想要模态......你可以使用:

newView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
//deprecated 6.0
//   [self presentModalViewController:newView animated:YES];
//from 5.0
[self presentViewController:newView animated:YES completion:NULL];
于 2012-12-16T02:42:46.003 回答