objective c - data not passing between view Controllers cannot solve -
i attempting pass string between 2 view controllers, first named detailcontroller , second videocontroller. connected button using push segue. "prepareforsegue" method being called, string returning null in videocontroller. have been stuck on problem ages , still cannot find solution. appreciated.
detailcontroller.m prepareforsegue method
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { nsstring *mystring=self.city.camera; nslog(@"%@", mystring); nsstring *see=@"what going on?"; nslog(@"%@", see); videocontroller *video= (videocontroller *) segue.destinationviewcontroller; video.cam= self.city.camera; }
videocontroller.m
#import "videocontroller.h" #import "city.h" #import "detailcontroller.h" #import "viewcontroller.h" @interface videocontroller () @end @implementation videocontroller @synthesize webview,city,cam; - (void)viewdidload { nsstring *see = self.cam; nslog(@"%@", see); [super viewdidload]; // additional setup after loading view. [self performselector:@selector(yourmethod) withobject:nil afterdelay:10.0]; nsstring * html = [nsstring stringwithformat:@"<img name=\"cam\" src=\"%@\" width=\"110%%\" height=\"100%%\" alt=\"live feed\" style=\"background-color: #000000\" />", cam]; [webview loadhtmlstring:html baseurl:nil]; } -(void)yourmethod { [self.navigationcontroller popviewcontrolleranimated:yes]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end
here messages receiving when button pushed , segue takes place. if reading correctly (null) being returned same webview other 2 strings when should coming within different webview? totally lost problem
2014-04-21 02:20:23.093 webview[47963:1a303] http://admin:*******@192.168.1.80/video.cgi/ 2014-04-21 02:20:23.094 webview[47963:1a303] going on? 2014-04-21 02:20:23.102 webview[47963:1a303] (null)
here videocontroller.h file, can see sam set strong, missing something?
#import <uikit/uikit.h> #import "detailcontroller.h" @class city; @interface videocontroller : uiviewcontroller{ iboutlet uiwebview *webview; iboutlet uiimageview *image; } @property (strong,nonatomic) city *city; @property (strong, nonatomic)nsstring * cam; @property(nonatomic,retain) uiwebview *webview; @end
see comment:
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { nsstring *mystring=self.city.camera; nslog(@"%@", mystring); nsstring *see=@"what going on?"; nslog(@"%@", see); videocontroller *video= (videocontroller *) segue.destinationviewcontroller; // sure self.city.camera has value // think assign nil video.cam video.cam= self.city.camera; }
Comments
Post a Comment