POP-UP UIView IMDB App style [затворено]

Има ли лесен начин за постигане на този вид изскачащ прозорец (както има с UIPopoverController) или трябва да го създам от нулата?

http://dl.dropbox.com/u/1898217/la-foto.jpg


person Roberto    schedule 24.02.2011    source източник


Отговори (1)


Можете да направите нещо подобно от нулата доста лесно. Номерът е да накарате контролера си за popover view да има прозрачен слой на цял екран

От вашия основен изглед:

self.popoverController = [[PopoverController alloc]
                                  initWithNibName:@"PopoverViewController" bundle:nil];
self.popoverController.view.frame =
    CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);

[self.view addSubview:self.popoverController.view]; // view is the transparent background
[self.popoverController viewWillAppear:NO];

Сега е само въпрос на внедряване на viewWillAppear, ако искате ефекти на преход:

- (void) viewWillAppear:(BOOL)animated {
    self.fadeView.alpha = 1.0f;
    self.view.alpha = 0.0;
    [self slideIn];
}

// Slide in with whatever effects you want your popup to use
- (void) slideIn {
    //set initial location at bottom of view (my popup slid in from the bottom)

    CGRect frame = self.configView.frame;
    frame.origin = CGPointMake(0.0, self.view.bounds.size.height);
    self.configView.frame = frame;
    [self.view addSubview:self.configView];

    //animate to new location, determined by height of the view in the NIB
    [UIView beginAnimations:@"presentWithSuperview" context:nil];
    [UIView setAnimationDuration:0.5];

    self.view.alpha = 1.0; // fade in background

    frame.origin = CGPointMake(0.0, self.view.bounds.size.height -self.configView.bounds.size.height);
    self.configView.frame = frame; // animate in popup

    [UIView commitAnimations];
}

- (void) slideOut {
    [UIView beginAnimations:@"removeFromSuperviewWithAnimation" context:nil];
    [UIView setAnimationDuration:0.5];
    self.view.alpha = 0.0;
    // Set delegate and selector to remove from superview when animation completes
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

    // Move this view to bottom of superview (my popup slides back to the bottom when finished)
    CGRect frame = self.configView.frame;
    frame.origin = CGPointMake(0.0, self.view.bounds.size.height);
    self.configView.frame = frame;

    [UIView commitAnimations];
}

// Finally remove the views when you're done animating out.
- (void) animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
    if ([animationID isEqualToString:@"removeFromSuperviewWithAnimation"]) {
        [self.configView removeFromSuperview];
        [self.view removeFromSuperview];
    }
}

За бонус точки можете да направите прозрачния фон контрол и да го накарате да открива докосвания за това кога изскачащият прозорец трябва да изчезне. Използвах създателя на интерфейс, за да извикам действие, което извиква slideOut.

person Winder    schedule 24.02.2011
comment
Добро! Тъй като го изграждаме от нулата, колко трудно е да анимираме изгледа с това 3D обръщане, което има IMDB? Никога не съм правил 3D анимации, дори не знам откъде да започна. Благодаря Виндер. - person Roberto; 25.02.2011
comment
CATransform3DMakeRotation беше отговорът. :-) - person Roberto; 28.02.2011
comment
Може ли някой да обясни този код малко по-подробно, моля? Много задължен. Благодаря! - person Sohan; 20.06.2011
comment

В крайна сметка просто използвах стъпката на Windows Batch Script. Трябваше да поставя папката NANT в PATH и винаги да изпълнявам скрипта като:

nant.exe -buildfile:xxx.build

Нямах време да проуча по-нататък, нито смятам, че това трябва да е голям проблем.

- person Winder; 21.06.2011
comment
Схванах го. Сега изглежда лесно :-) Благодаря @Winder! - person Sohan; 21.06.2011