首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIActionSheet定制

UIActionSheet定制
EN

Stack Overflow用户
提问于 2010-10-19 19:51:33
回答 1查看 619关注 0票数 0

你能控制文本的大小和它在操作表上的对齐方式吗?另外,你能决定destructivebutton和其他按钮在动作单上的出现顺序吗?像屏幕一样的截图是我试图创建的。

提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-10-19 21:12:37

我做了一些类似的事情来定制一个Action Sheet:

-(void) showPopup { unitPicker *pc = [unitPicker alloc ];UIActionSheet *popupQuery = [UIActionSheet alloc:@“Units”delegate:pc cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil ];

代码语言:javascript
复制
[pc setParent:self];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;    
[popupQuery showInView:self.view];

[popupQuery setBounds:CGRectMake(0,0,320, 350)];

[pc setAs:popupQuery];
[popupQuery addSubview:pc.view];

}

诀窍在于"unitPicker“是从UIControllerView派生出来的,但是实现了UIActionSheetDelegate协议。它提供了两个函数:

代码语言:javascript
复制
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex;
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;

来处理任何清理工作。最重要的一点是,与任何UIViewController一样,unitPicker的格式也是从一个NIB创建的。

视图中的按钮使用其touchUpInside处理程序中的代码解除了actionSheet:

代码语言:javascript
复制
[as dismissWithClickedButtonIndex:0 animated:TRUE];

(您可以在上面的代码中看到,"as“被设置为actionSheet对象)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3967992

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档