开发者

how can an UIAlertView button calls another function?

开发者 https://www.devze.com 2023-03-19 01:34 出处:网络
-(void)buPressed{ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@\"Game Over\" message:@\"YOU LOST! ALL YOUR BASE ARE BELONG TO US!\"
 -(void)buPressed{

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Game Over"
                                                        message:@"YOU LOST! ALL YOUR BASE ARE BELONG TO US!"
                                                       delegate:self
                                              cancelButtonTitle:@"Cancel"
                                              otherButtonTitles:@"Publish", nil];

    [alertView show];
    [alertView re开发者_高级运维lease];

    }

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if(buttonIndex==0){
        NSLog(@"%d",buttonIndex);

    }
    else{
        [self bPressed];
    }   

    }

    -(void)bPressed{

    ModalViewConroller *yeniSayfa=[[ModalViewConroller alloc] init];

    yeniSayfa.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;

    [self presentModalViewController:yeniSayfa animated:YES];

    [yeniSayfa release];

    //Restore to Defaults
    [button_1 setSelected:NO];
    [button_2 setSelected:NO];
    [button_3 setSelected:NO];
    [button_4 setSelected:NO];
    [button_5 setSelected:NO];
    [button_6 setSelected:NO];
    slider.value=50.00;
    UIImage *image = [UIImage imageNamed:@"Smiley_00025.png"];
    imageView = [[UIImageView alloc] initWithImage:image];
    imageView.frame = CGRectMake(81, 43, image.size.width, image.size.height);  
    [self.view addSubview:imageView];


    }

This is my code i want to make the publish button to call bPressed function but it is giving a warning and the program crashes when i touch the publish button i want to open a modalview when i push the publish button can anybody help me?


You need to declare the function in your header file so that other objects (in this case an instance of UIAlertView, since its delegate is set to your class) know that this method exists.

So, in your whatever_class.h file, add the following line below the @interface{ }:

-(void)bPressed;
0

精彩评论

暂无评论...
验证码 换一张
取 消