viewDidload方法调用问题

时间:2012-12-13 10:18:33

标签: ios5

-(void)viewDidLoad{
[self.view setBackgroundColor:[UIColor whiteColor]];
isInFullScreenMode = FALSE;

messageArrayCollection = [[NSMutableArray alloc] init];

for (int i = 1; i <= 18; i++) {

    MessageModel* messageModel1 = [[MessageModel alloc] init];
    messageModel1.messageID= i;
    messageModel1.userName = @"Kimberly A. Mann";
    messageModel1.userImage =  @"MWMStaff.png";
    messageModel1.createdAt = @"06/07/2011 at 01:00 AM";
    messageModel1.content = @"After raising her two children, Kim joined the Monument Wealth Management team in 2009, managing the book keeping and other office tasks.In her free time, Kim enjoys spending time with her family, attending festive events and parades, and catching up on her favorite shows – Dancing with the Stars and Smash, to name a few";


    [messageArrayCollection addObject:messageModel1];
    //[messageModel1 release];
}

[self buildPages:messageArrayCollection];

flipper = [[AFKPageFlipper alloc] initWithFrame:self.view.bounds];
flipper.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
flipper.dataSource = self;
[self.view addSubview:flipper];
}


-(void)showViewInFullScreen:(UIViewExtention*)viewToShow withModel:(MessageModel*)model{
   NSLog(@" in show view inFullscreen");
  if (!isInFullScreenMode) {
    isInFullScreenMode = TRUE;

    CGRect bounds = [UIScreen mainScreen].bounds;
    if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        CGFloat width = bounds.size.width;
        bounds.size.width = bounds.size.height;
        bounds.size.height = width;
    }


    fullScreenBGView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height)];
    fullScreenBGView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [fullScreenBGView setBackgroundColor:RGBACOLOR(0,0,0,0.6)];
    fullScreenBGView.alpha = 0;
    [self.view addSubview:fullScreenBGView];

    viewToShowInFullScreen =  viewToShow;
    viewToShowInFullScreen.originalRect = viewToShowInFullScreen.frame;
    viewToShowInFullScreen.isFullScreen = TRUE;
    FullScreenView* fullView = [[FullScreenView alloc] initWithModel:model];
    fullView.frame = viewToShowInFullScreen.frame;
    fullView.viewToOverLap = viewToShowInFullScreen;
    fullView.fullScreenBG = fullScreenBGView;
    fullScreenView = fullView;

    [self.view addSubview:fullView];

    [self.view bringSubviewToFront:fullScreenBGView];
    [self.view bringSubviewToFront:fullView];

    [UIView beginAnimations:@"SHOWFULLSCREEN" context:NULL];
    [UIView setAnimationDuration:0.40];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:nil cache:NO];
    fullScreenBGView.alpha = 1;
    if (self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        [fullView setFrame:CGRectMake(10, 50, 768-20, 1004-60)];
    }else {
        [fullView setFrame:CGRectMake(10, 50, 1024-20, 746-60)];
    }
    [fullScreenView rotate:self.interfaceOrientation animation:YES];
    [UIView setAnimationDelegate:self];
    [UIView   setAnimationDidStopSelector:@selector(animationEnd:finished:context:)];
    [UIView commitAnimations];

}


 }

通过点按屏幕的特定区域来显示showViewInFullScreen方法,以显示全屏视图,但是当到达[self.view addSubview:flipper];时,它将返回viewDidload方法,因此无法运行这个方法中的整个代码。并且根据行为它不应该使用此方法。为什么我无法在其上添加subview。搜索了很多关于[self.view addsubView]行为的信息。它应该添加{ {1}}到当前窗口。真的没有发生什么事。如果有人能说出这里有什么不对,那就会感激不尽。

0 个答案:

没有答案