1

UITabBar5 つのタブを持つプロジェクトがあります。
無料版と有料版の 2 つのターゲット バージョンを作成しています。

無料版では、ユーザーがタブ アイテム インデックス 3 または 4 に移動しようとUIAlertViewすると、次のような基本的なメッセージが表示されます。

アップグレードしますか?
はい / キャンセル

ボタンを押すCancelと、ビューは最初のView Controllerに移動する必要があります。
どうすればいいですか?

また、私の次の質問 (スタックで別の質問をする必要があることは承知しています) はUIAlertView、有料版で が表示されないようにする方法です。

タブ項目 3 & 4のボタンを使用するところまで来ましたUIAlertViewが、それはしたくありません。

2 つのターゲットは正常に機能しており、次のコードを使用しています。

- (IBAction)openAlert:(id)sender
{
#ifdef FREE

    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Attention" 
                                                       message:@"Choose option" 
                                                      delegate:self
                                             cancelButtonTitle:@"Cancel"
                                             otherButtonTitles:@"Download Full version", nil];
    [alertView show];

#endif
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex ==1) {
        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString  stringWithFormat:@"http://***.com"]]];
    }
}

どんな助けでも大歓迎です。

4

3 に答える 3

0

appdelegate をタブバー コントローラーのデリゲートとして設定し、この作業を appdelegate またはどこでも実行します。

  1. ユーザーがキャンセル ボタンを押して呼び出したとき

[yourTabbarController setSelectedIndex:0]

  1. 特定のバージョン(有料/無料)でアラートを回避するには、次のデリゲート メソッドにコードを記述します。
  • (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
于 2013-12-12T12:04:13.087 に答える
0

キャンセル時に別の に移動するにUIViewControllerは、self.tabBarControllerオブジェクトのsetSelectedIndex

例:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    switch (buttonIndex) {
        case 0:
            //Cancel button was clicked
            [self.tabBarController setSelectedIndex:0];
        break;
        case 1:
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString  stringWithFormat:@"http://***.com"]]];
        break;
    }
}

無料対有料に関しては、意見に基づいています。
基本的な方法の 1 つは、 を使用NSUserDefaultsしてアプリが無料版か有料版かを記憶し、それに応じてロジックを処理することです。

于 2013-12-12T12:14:42.323 に答える