投稿

4月, 2011の投稿を表示しています

UIAvtionSheetのキャンセルボタンが効かない?

ツールバーがあるとActionSheetのキャンセルボタンの下半分がきかない。 変更前 UIActionSheet *actionSheet = [[UIActionSheet alloc] init]; actionSheet.title = @"タイトル"; [actionSheet addButtonWithTitle:@"決定"]; [actionSheet addButtonWithTitle:@"キャンセル"]; actionSheet.cancelButtonIndex = 1; actionSheet.destructiveButtonIndex = 0; actionSheet.delegate = self; [actionSheet showInView:self.view]; 変更後 UIActionSheet *actionSheet = [[UIActionSheet alloc] init]; actionSheet.title = @"タイトル"; [actionSheet addButtonWithTitle:@"決定"]; [actionSheet addButtonWithTitle:@"キャンセル"]; actionSheet.cancelButtonIndex = 1; actionSheet.destructiveButtonIndex = 0; actionSheet.delegate = self; [sheet showInView:self.view.window];

UIAlertViewをカスタマイズするには

イメージ
UIAlertViewのカスタマイズにつまずいたのでメモ。 通常UIAlertViewを表示したい場合、以下のようなコードを作成する...と思う。 UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"タイトル" message:@"メッセージ" delegate:self cancelButtonTitle:@"キャンセル" otherButtonTitles:@"決定", nil] autorelease]; [alert show]; サイズを変更したかったので、showメソッドの前でframeを変更する。 が、考慮されない模様。 UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"タイトル" message:@"メッセージ" delegate:self cancelButtonTitle:@"キャンセル" otherButtonTitles:@"決定", nil] autorelease]; alert.frame = CGRectMake(0,0,150,150);//サイズ変更が考慮されない [alert show]; どうやら[alert show]した後でないとカスタマイズできない。 なので、以下のようにUIAlertViewDelegateの- (void)willPresentAlertView:(UIAlertView *)alertViewの中でalertViewのサイズを変更する。 -(void)willPresentAlertView:(UIAlertView *)alertView{ CGRect alertFrame = CGRectMake(0,0,320,360); alertView.frame = alertFrame; } 当然ながらサイズを変更するとボタンの位置も変更したくなるので、以下のコードで無理