NSString在传递给下一个ViewController时返回null

时间:2014-04-09 18:50:27

标签: ios objective-c uiviewcontroller null parameter-passing

我正在尝试将NSString相机从detailController传递到VideoController但是它在VideoController中返回null并且我似乎无法弄清楚问题。这是我的DetailController代码,使用 - (IBAction)行按一个按钮将VideoController推送到堆栈。

DetailViewController.m

#import "DetailController.h"
#import "City.h"
#import "VideoController.h"
#import "Helper.h"

@interface DetailController ()

@end

@implementation DetailController
@synthesize city, ClubName, Price, Vip, Promo, remain,p,deal,money,camera,cam,tweet,post;




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

- (void)viewDidLoad
{   
[super viewDidLoad];
UIImage *highlightedButtonImage = [UIImage imageNamed:@"twitter.png"]; 

[Helper customizeBarButton:self.tweet image:highlightedButtonImage highlightedImage:highlightedButtonImage];

UIImage *faceButtonImage = [UIImage imageNamed:@"facebook.png"]; 

[Helper customizeBarButton:self.post image:faceButtonImage highlightedImage:faceButtonImage];


// Do any additional setup after loading the view.
UIFont *labelFont=[UIFont fontWithName:@"Deutsch Gothic" size:20.0];
UIFont *myFont=[UIFont fontWithName:@"Deutsch Gothic" size:30.0];
UIFont *titleFont=[UIFont fontWithName:@"Deutsch Gothic" size:40.0];
NSString * name= self.city.clubName;
NSString * line= self.city.clubLine;
NSString * description= self.city.promo;
NSString * price= self.city.price;
cam=self.city.camera;
NSLog(@"%@", cam);



remain.font=labelFont;
remain.text=@"VIP Remaining :";
p.font=labelFont;
p.text=@"Price :";
money.font=myFont;

deal.font=labelFont;
deal.text=@"Promotions :";

ClubName.font=titleFont;
ClubName.text=name;
Vip.font=myFont;
Vip.text=line;
Price.font=myFont;
Price.text=price;
Promo.font=labelFont;
Promo.text=description;



}




- (IBAction)line:(id)sender {
VideoController *vc2 = [[VideoController alloc]initWithNibName:@"VideoController" bundle:nil];
[vc2 setCam:self.city.camera];
[self.navigationController pushViewController:vc2 animated:YES];
}
@end

VideoController.m

#import "VideoController.h"
#import "City.h"

@interface VideoController ()

@end

@implementation VideoController
@synthesize webView,city,cam;



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

- (void)viewDidLoad
{  
NSLog(@"%@", cam); // cam returns null here

image.animationImages = [NSArray arrayWithObjects:
                         [UIImage imageNamed:@"32.tiff"],
                         [UIImage imageNamed:@"31.tiff"],
                         [UIImage imageNamed:@"30.tiff"],
                         [UIImage imageNamed:@"29.tiff"],
                         [UIImage imageNamed:@"28.tiff"],
                         [UIImage imageNamed:@"27.tiff"],
                         [UIImage imageNamed:@"26.tiff"],
                         [UIImage imageNamed:@"25.tiff"],
                         [UIImage imageNamed:@"24.tiff"],
                         [UIImage imageNamed:@"23.tiff"],
                         [UIImage imageNamed:@"22.tiff"],
                         [UIImage imageNamed:@"21.tiff"],
                         [UIImage imageNamed:@"20.tiff"],
                         [UIImage imageNamed:@"19.tiff"],
                         [UIImage imageNamed:@"18.tiff"],
                         [UIImage imageNamed:@"17.tiff"],
                         [UIImage imageNamed:@"16.tiff"],
                         [UIImage imageNamed:@"15.tiff"],
                         [UIImage imageNamed:@"14.tiff"],
                         [UIImage imageNamed:@"13.tiff"],
                         [UIImage imageNamed:@"12.tiff"],
                         [UIImage imageNamed:@"11.tiff"],
                         [UIImage imageNamed:@"10.tiff"],
                         [UIImage imageNamed:@"9.tiff"],
                         [UIImage imageNamed:@"8.tiff"],
                         [UIImage imageNamed:@"7.tiff"],
                         [UIImage imageNamed:@"6.tiff"],
                         [UIImage imageNamed:@"5.tiff"],
                         [UIImage imageNamed:@"4.tiff"],
                         [UIImage imageNamed:@"3.tiff"],
                         [UIImage imageNamed:@"2.tiff"],
                         [UIImage imageNamed:@"1.tiff"],nil];

[image setAnimationRepeatCount:1];
image.animationDuration = 10.0;
[image startAnimating];
[super viewDidLoad];
// Do any additional setup after loading the view.

[self performSelector:@selector(yourMethod) withObject:nil afterDelay:10.0];



}
-(void)yourMethod
{
[self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

0 个答案:

没有答案