ios - -(void) loadView with NSMutableArray -
- (void)loadview { [super loadview]; arrayofimages = [[nsmutablearray alloc]initwithobjects:@"11.jpg",@"22.jpg",@"33.jpg", nil]; uiimageview *awesomeview = [[uiimageview alloc] initwithframe:cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; [awesomeview setimage :[uiimage imagenamed:[arrayofimages objectatindex:0]]]; awesomeview.contentmode = uiviewcontentmodescaleaspectfit; [self.view addsubview:awesomeview]; nslog(@"%@",[arrayofimages objectatindex:0]); }
when put nsmutablearray
in -(void)viewdidload
, uiimageview
displays nothing , nslog
shows null. why that?
ps. nsmutablearray worked in -(void)loadview
. i've declared nsmutablearray *arrayofimage in @interface .h file
the way given output "null" in situation arrayofimages
null
itself.
this possible if arrayofimages
declared weak variable.
but @maddy pointed out, code wrong: don't call super, assign self.view
. or use vieddidload
instead (probably want here).
Comments
Post a Comment