2011-07-07 48 views
3
-(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 release]; 

    } 

    - (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]; 


    } 

這是我的代碼,我想使發佈按鈕來調用bPressed函數,但它是給出警告和程序崩潰時,我觸摸發佈按鈕我想打開一個modalview時,我推按鈕發佈可以任何人幫我?UIAlertView按鈕如何調用另一個函數?

+0

你得到哪些警示? –

+0

方法-bPressed找不到 –

+0

你在頭文件中指定了這個方法嗎? –

回答

1

您需要在頭文件中聲明函數,以便其他對象(在本例中爲UIAlertView的實例,因爲它的委託設置爲您的類)知道此方法存在。

因此,在你whatever_class.h文件中添加以下@interface{ }下面一行:

-(void)bPressed; 
+0

非常感謝Sascha –