0

私のアプリケーションでは、画像の変更をクリックすると、UIActionsheet に、写真を撮る、ライブラリから選択する、キャンセルするという 3 つのアクションが要求されます。これは私のコードです

    - (void)viewDidLoad
{
         [super viewDidLoad];
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..."
        delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from library", nil];
        actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
        actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
        [actionSheet showInView:self.view];
}
4

5 に答える 5

2

その理由は...ビューサイズとしてデフォルトのビューサイズ-Retina 4フルスクリーンを使用していると思います...属性インスペクターからビューサイズをRetina 3.5フルスクリーンに変更してみてください...!!!

于 2013-07-29T11:22:22.823 に答える
1

これを試してください...

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..." 
                                                         delegate:self
                                                cancelButtonTitle:@"Cancel"
                                           destructiveButtonTitle:@"Cancel"
                                                otherButtonTitles:@"Take Photo", @"Choose from library", nil];

    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
    [actionSheet showInView:self.view];
于 2013-07-29T10:50:17.183 に答える
1

クラス リファレンスで、アクション シートを表示するための代替方法を参照することをお勧めします。ただし、次のいずれかを使用してみてください (ツールバーがある場合)。

– showFromBarButtonItem:animated:
– showFromToolbar:

さらに、以下を使用して

actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

アクションシートスタイルがデフォルトになるだけです。

于 2013-07-29T10:50:36.847 に答える
0

あなたの問題はあなたのコードではないので。UIActionSheet を表示するために間違った方法を使用している可能性があります。

UIActionSheet は、次のメソッドで表示できます。

– showFromTabBar:
– showFromToolbar:
– showInView:
– showFromBarButtonItem:animated:
– showFromRect:inView:animated:

Apple の UIActionSheet リファレンスを見てください。

TabBar を使用しているため、[キャンセル] ボタンも下にある場合があります。私もそれをテストします。

于 2013-07-29T11:24:07.273 に答える
0

このリンクを参照してください。

また、以下のコードも参照できます。役立つ場合があります。

(void)viewDidLoad
    {

    UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from library", nil];
    [actionSheet showInView:self.view];

    }
于 2013-07-29T11:20:37.203 に答える