如何使用UIAlert打开NIB或UIView

时间:2009-11-26 00:06:06

标签: objective-c uialertview

到目前为止,这是我的代码,我可以获得一个工作网址,但我想从此警报标签中加载一个笔尖

- (IBAction)aboutAction { // The action called when the about button is clicked.
        UIAlertView * aboutView = [[UIAlertView alloc] initWithTitle:@"Alert:" // Create a new UIAlertView named aboutScreen, and allocate it. Set the title to "About" 
                                                             message:@"MESSAGE GOES HERE" 
                                                            delegate:self 
                                                   cancelButtonTitle:@"Got It Thanks!"  
                                                   otherButtonTitles:@"Donate Now", nil]; 

            [aboutView show]; // Show the UIAlertView on the screen.
            [aboutView release]; // Release the UIAlertView from the memory.
    }


    -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
                if(buttonIndex == 1) { //Not sure what to do here.
                }

    }

2 个答案:

答案 0 :(得分:1)

-(void) alertView:(UIAlertView *) alertview clickedButtonAtIndex:(NSInteger)buttonIndex {

    switch (buttonIndex) {

        case 1: {
            Accidenthelpercall *help = [[Accidenthelpercall alloc] initWithNibName:nil bundle:nil];
            [self presentModalViewController:help animated:NO];
        }


        case 2: {

            Accidentdamagecar *damagecar = [[Accidentdamagecar alloc] initWithNibName:nil bundle:nil];
            [self presentModalViewController:damagecar animated:NO];

        }
}

答案 1 :(得分:0)

-(void) alertView:(UIAlertView *) alertview clickedButtonAtIndex:(NSInteger)buttonIndex {

    switch (buttonIndex) {

        case 1: {
            Accidenthelpercall *help = [[Accidenthelpercall alloc] initWithNibName:nil bundle:nil];
            [self presentModalViewController:help animated:NO];
            [help release];
        }


        case 2: {

            Accidentdamagecar *damagecar = [[Accidentdamagecar alloc] initWithNibName:nil bundle:nil];
            [self presentModalViewController:damagecar animated:NO];
            [damagecar release];

        }
}