簡體   English   中英

當按下UIBarButtonItem時顯示UIAlertView

[英]Display UIAlertView when UIBarButtonItem is pressed

我有一個UIBarButtonItem,我想在按下它時顯示一個UIAlertView。

我嘗試了IBAction,添加手勢等,但找不到一個好的解決方案。 有任何想法嗎?

我嘗試了這個:

-(IBAction)helpButton:(UIBarButtonItem *)sender{
    NSString* title;
    NSString* message;
    NSString* yesButtonText;
    NSString* noButtonText;

    tutorialAlertView = [[UIAlertView alloc] initWithTitle:title 
        message:message 
        delegate:self 
        cancelButtonTitle:nil 
        otherButtonTitles:yesButtonText, noButtonText, nil];

    tutorialAlertView.delegate = self;
    [tutorialAlertView show];
}

我添加了以下內容,現在可以使用:

helpButton = [[UIBarButtonItem alloc] initWithTitle:@"Help" style:UIBarButtonItemStylePlain target:self action:@selector(helpButton:)];
self.navigationItem.rightBarButtonItem = helpButton;

您兩次聲明了委托= self,請嘗試刪除另一個。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM