gpt4 book ai didi

iphone - 如何在UIActionSheet中显示自定义 View ?

转载 作者:行者123 更新时间:2023-12-03 20:11:13 25 4
gpt4 key购买 nike

我有一个带有日期选择器的 UIView,我想将其显示在操作表中。我正在使用以下代码:

-(IBAction) button_click:(id)sender{
//UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"the title" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destructive" otherButtonTitles:@"other", nil];

UIActionSheet *sheet = [[UIActionSheet alloc] init];
ActionSheetController *actionSheet = [[ActionSheetController alloc] initWithNibName:@"ActionSheetView" bundle:nil];
[sheet addSubview:actionSheet.view];

[sheet showInView:self.view];
}

我得到的是新 View 的顶部部分从底部升起,仅此而已。如果我注释中间的两行代码并取消注释顶部部分以显示常规操作表,则它可以正常工作。有什么想法我可能做错了什么吗?

最佳答案

使用 UIActionSheetDelegate,之后您可以使用此委托(delegate)将图像添加到警报表的按钮

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet{

UIImageView *sample = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"Someimage.png"]];
[actionSheet addSubView:sample];

}

关于iphone - 如何在UIActionSheet中显示自定义 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2616047/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com