Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIActionSheet中的UIView_Iphone_Xcode4.5_Uiactionsheet - Fatal编程技术网

Iphone UIActionSheet中的UIView

Iphone UIActionSheet中的UIView,iphone,xcode4.5,uiactionsheet,Iphone,Xcode4.5,Uiactionsheet,我在UIActionSheet中添加了一个UIView,我需要在视图上添加四个标签和一个关闭按钮。但是我需要UIActionSheet从屏幕中央开始。当我粘贴尺寸时,我无法获得它 -(IBAction)buttontapped:(id)sender{ UIView *showDetailsView = [[UIView alloc]initWithFrame:CGRectMake(0,10, 320, 260)]; showDetailsView.backg

我在
UIActionSheet
中添加了一个
UIView
,我需要在视图上添加四个标签和一个关闭按钮。但是我需要UIActionSheet从屏幕中央开始。当我粘贴尺寸时,我无法获得它

-(IBAction)buttontapped:(id)sender{


     UIView    *showDetailsView = [[UIView alloc]initWithFrame:CGRectMake(0,10, 320, 260)];

        showDetailsView.backgroundColor = [UIColor whiteColor];

        UILabel  *name =[[UILabel alloc] init];
        [name setFrame:CGRectMake(10, 40,250, 50)];
        name.textAlignment = UITextAlignmentLeft;
        name.backgroundColor = [UIColor clearColor];
        name .font=[UIFont fontWithName:@"arial" size:12];
        name.text=@"Name";
        [showDetailsView addSubview:name];


        UIActionSheet *aac = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil  otherButtonTitles:@"Close", nil];
        aac.actionSheetStyle = UIActionSheetStyleAutomatic;
        [aac addSubview:showDetailsView];
        [aac setFrame:CGRectMake(0,0,320,400)];
        [aac showInView:self.view];

}
我可以看到它是从底部添加的,但它没有像下图那样扩展到屏幕中心:我需要增加它的高度。

使用此选项:

[aac setBounds:CGRectMake(0,0,320,400)];

UIActionSheet设计为从屏幕底部显示

你只能在ipad的中央显示,而不能在iphone上显示

您可以根据需要使用自定义Alertview


当你展示行动表时,你需要发送适当的信息来展示它。指

对于showInView:,您可以拥有一个不可见视图,底部位于视图控制器的中间高度,顶部与视图控制器的顶部对齐


对于showFromRect:inView:animated:,如果您有任何需要锚定操作表的UIView,您可以在那里使用它。

从SO的一个答案中,我得到了这个方法,它的工作原理类似于charm:)

这里的
myActionSheet
是一个
UIActionSheet
iVar。
这里的
myPicker
是一个
UIPickerView
iVar 您可以设置所需的值,而不是
214
静态值,并据此设置
UIActionSheet
的高度

注意

必须在显示操作表之后调用,即在
[self.myActionSheet showFromTabBar:self.tabBarController.tabBar]之后调用代码行的类型。是指在调用操作表上的
show
方法之后。

我已经使用了它。但是没有运气,我可以进一步修改什么?只需注释这一行[aac addSubview:showtailsview];我只得到了UIactionsheet,但我需要向其中添加UIView,因为我想在其中显示一些标签。@Sindhia[aac showInView:self.view];[aac立根:CGRectMake(0,0320400)];实际上,不管它是从屏幕底部开始的,但它并没有扩展到中心。我的UIActionsheet就在屏幕底部。如果您希望它位于屏幕底部以外的其他位置,则可以在显示操作表时使用showFromRect:方法。[actionSheet showFromRect:CGRectMake(0,0320,10)inView:placeholderview动画:是];Hi要拍摄特定窗口的屏幕截图,请使用shift+command+4,然后空格,然后单击所需窗口。
-(void)setActionSheetHeight
{
    CGRect actionSheetRect = self.myActionSheet.frame;
    CGFloat orgHeight = actionSheetRect.size.height;
    actionSheetRect.origin.y -= 214; //height of picker
    actionSheetRect.size.height = orgHeight+214;
    self.myActionSheet.frame = actionSheetRect;

    [self.myPicker setShowsSelectionIndicator:YES];

    CGRect pickerRect = self.myPicker.frame;
    pickerRect.origin.y = orgHeight;
    self.myPicker.frame = pickerRect;
}