【问题标题】:adding view into action sheet将视图添加到操作表中
【发布时间】:2011-03-22 10:38:24
【问题描述】:

我可以将我的自定义 UIViewController 添加到 ActionSheet 中吗?

谢谢

【问题讨论】:

  • 你想解释什么。但是您不能在操作表中添加完整视图
  • 感谢回复...请参阅我想添加一个视图,它是 uiviewcontroller 的子类。在这个视图中,我添加了一个图像视图作为背景图像和一个用于显示 XML 解析数据的表格。现在我想将此视图添加到操作表中。就这些

标签: iphone uiactionsheet


【解决方案1】:

我终于找到了...我已将 UIViewController 子类的视图添加到 UIActionSheet 中。我在单独的文件中创建了一个视图(使用 xib)。

UIActionSheet *asheet = [[UIActionSheet alloc] init];
[asheet showInView:self.view]; 
[asheet setFrame:CGRectMake(0, 230, 320, 230)];


CustomView *innerView = [[CustomView alloc] initWithNibName:@"CustomView" bundle:nil];
innerView.view.frame = CGRectMake(0, 10, 320, 210);
[asheet addSubview:innerView.view];
//[asheet addSubview:innerView];

[innerView release];
[asheet release];

【讨论】:

  • 使用“[[UIActionSheet alloc] initWithTitle:@"a" delegate:nil cancelButtonTitle:@"cancel" 破坏性ButtonTitle:@"destroy" otherButtonTitles:@"ok", nil];"产生更好的显示动画
【解决方案2】:

我最近创建了一个应用程序,我在其中创建了操作表并在其中添加了一个选择器视图。
首先,您需要在 .h 文件中为操作表创建对象及其属性,如下所示:

UIActionSheet *menuProperty;    

@property(nonatomic,retain) UIActionSheet *menuArea;  

然后你需要在你的 .m 文件中进行以下更改

menuArea = [[UIActionSheet alloc] initWithTitle:nil  delegate:self
                                            cancelButtonTitle:@"Done"  
                                        destructiveButtonTitle:nil
                                             otherButtonTitles:nil];  


// Add the picker  
pickerArea = [[UIPickerView alloc] initWithFrame:CGRectMake(0,185,0,0)];  

pickerArea.delegate = self;  
pickerArea.showsSelectionIndicator = YES;    // note this is default to NO  

[menuArea addSubview:pickerArea];  
[menuArea showInView:self.view];  
[menuArea setBounds:CGRectMake(0,0,320, 600)];  

【讨论】:

  • 如何设置动作表从顶部的高度?尝试使用 asheet setFrame:CGRectMake(0, 110, 320, 210)。我想从顶部减少而不是从底部减少。谢谢
  • 我将其更改为 setFrame:CGRectMake(0,40,320,600)。在这里工作正常。
  • Action Sheet 看这个例子
【解决方案3】:

我认为这些链接会帮助你。我从未在 uiactionsheet 中添加视图,但经过一番搜索后我认为我们可以添加。

http://www.ifans.com/forums/showthread.php?t=301851

how add the action sheet in the cell of table view

【讨论】:

    猜你喜欢
    • 2015-12-23
    • 1970-01-01
    • 2018-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-21
    • 1970-01-01
    • 2011-06-08
    相关资源
    最近更新 更多