在iPad上使用UIActionSheet,效果怎么和ipad iphone 同步中不一样阿

主题 : 请问uiactionsheet列表中最下方的按钮为什么点下半部分没反应?
级别: 侠客
可可豆: 991 CB
威望: 991 点
在线时间: 114(时)
发自: Web Page
来源于&&分类
请问uiactionsheet列表中最下方的按钮为什么点下半部分没反应?&&&
比如说最下方的按钮是“取消”,只能点此按钮的上半部分才有效,点下半部分是无效的,在模拟器和真机上都是如此,这啥办呢?
级别: 精灵王
可可豆: 6260 CB
威望: 6260 点
在线时间: 450(时)
发自: Web Page
回 楼主(xinux) 的帖子
你有tabbar。把acitonsheet加到window上。
级别: 侠客
可可豆: 991 CB
威望: 991 点
在线时间: 114(时)
发自: Web Page
谢谢了![actionSheet showInView:[UIApplication sharedApplication].keyWindow];
级别: 新手上路
可可豆: 82 CB
威望: 32 点
在线时间: 124(时)
发自: Web Page
学到知识 了 ,thank you
级别: 新手上路
可可豆: 33 CB
威望: 33 点
在线时间: 25(时)
发自: Web Page
正好碰到这个问题,谢谢了。
级别: 新手上路
可可豆: 93 CB
威望: 126 点
在线时间: 50(时)
发自: Web Page
多谢,我也是遇到这样的问题
级别: 新手上路
UID: 156840
可可豆: 94 CB
威望: 93 点
在线时间: 118(时)
发自: Web Page
原来是这样
关注本帖(如果有新回复会站内信通知您)
8*2-5 正确答案:11
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:
Apple's documentation for the UIActionSheet is causing me confusion. First off, in the iPad Human Interface Guidelines, it says :
To learn more about using an action sheet in your code, see “Using Popovers to Display Content” in iPad Programming Guide.
But then in the "Using Popovers to Display Content" section, it doesn't mention Action Sheets at all! Am I missing something here?
My main question is this: on the iPad, what is the difference between a UIPopoverController and a UIActionSheet? If a UIActionSheet automatically presents itself inside a UIPopoverController, is there any reason to use UIActionSheet at all? I see how its delegate and automatic creation of buttons makes for fewer lines of code, but from a usability POV, is there a difference?
Also, displaying my actionSheet with animation is not working at all. It looks and acts exactly like an actionSheet presented without animation (which is exactly the same as if I were just using a UIPopoverController and no actionSheet at all). Here's my code:
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"An unsaved property already exists. You must assign a name to this property before creating a new property. Would you like to:"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:@"Overwrite"
otherButtonTitles:@"Open unsaved property", nil];
[action showFromRect:CGRectMake(0, 0, 200, 200) inView:self.mainSplitViewController.view animated:NO];
How would I get an actionSheet that looks like the sample animated actionSheet in Apple's documentation (from the maps application, where you add a location to a contact)?
I may just end up using an alert for this rather than a popover or an actionSheet, but it would still be useful to understand this.
6,79744081
First of all, UIActionSheet existed before UIPopoverController and UIPopoverController isn't available on iPhone, so it's useful for backwards compatibility and universal apps.
Also, a UIActionSheet isn't necessarily presented in a popover, specifically, if you show it from a UIBarButtonItem or UIToolbar that is already inside a popover. It is then presented in a similar fashion as on the iPhone (sliding in from the bottom of the view controller). According to the HIG, you must not present multiple popovers at the same time (I once had an app rejected for that), so in cases where a view controller may be inside a popover (like in a standard split view app), you may want to use action sheets, if possible. Of course there are a lot of cases where you can't replace a popover with an action sheet, because an action sheet only shows a list of buttons and a title, whereas a popover can display any view controller.
I think that the animated parameter only has an effect when an action sheet is presented in the "classic" (as on iPhone) way.
43.9k594120
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Upcoming Events
ends Nov 24
Stack Overflow works best with JavaScript enabledUIActionSheet:
首先,在.h文件中添加Protocol,(Protocol相当于Java中的interface)
@interface ActionSheetViewController : UIViewController
&UIActionSheetDelegate&
-(IBAction) showActionSheetButtonPressed:(id)
-(IBAction) showAlterViewButtonPressed:(id)
在.m文件中实现showActionSheetButtonPressed 方法。
-(IBAction) showActionSheetButtonPressed:(id) sender&
UIActionSheet *actionSheet = [[UIActionSheet alloc]&
&&initWithTitle:@&Title&
&&delegate:self
&&cancelButtonTitle:@&Cancel!&&
destructiveButtonTitle:@&OK!&&
&&otherButtonTitles:nil];
[actionSheet showInView:self.view];//参数指显示UIActionSheet的parent。
[actionSheet release];
一个IUActionSheet在用户点击Button的时调用,但是当用户选择了destructiveButton或者cancelButton后,如何处理想对应的事件呢?
在UIActionSheetDelegate中,有一个方法,
-(void) actionSheet :(UIActionSheet *) actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;
我们需要实现这个方法就可以了。
-(void) actionSheet :(UIActionSheet *) actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex
//当用户按下cancel按钮
if( buttonIndex == [actionSheet cancelButtonIndex])
// DoSomething here.
//当用户按下OK按钮
if( buttonIndex == [actionSheet destructiveButtonIndex])
// DoSomething here.
UIAlertView:
-(IBAction) showAlterViewButtonPressed:(id) sender
UIAlertView *alertView = [[UIAlertView alloc]&
&&initWithTitle:@&Alert Title&&
&&message:@&Alter Message Content&&
&&delegate:self&
&&cancelButtonTitle:@&OK&&
&&otherButtonTitles:nil];
[alertView show];
[alertView release];
UIAlterView相对于UIActionSheet简单,以为它只是一个提示用户的View而已。可以在 UIActionSheet的的处理事件 -(void) actionSheet ...中来调用UIAlterView.
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:387647次
积分:4611
积分:4611
排名:第3204名
原创:61篇
转载:137篇
评论:99条
(3)(1)(1)(1)(1)(2)(1)(2)(4)(1)(2)(1)(2)(4)(5)(7)(5)(2)(1)(1)(7)(3)(1)(13)(15)(5)(8)(11)(3)(6)(2)(1)(1)(3)(1)(1)(1)(2)(7)(6)(1)(7)(1)(1)(1)(2)(4)(2)(4)(15)(1)(2)(2)(1)(1)(1)(8)主题 : 这是UIActionSheet的bug?
级别: 骑士
可可豆: 1956 CB
威望: 1956 点
在线时间: 385(时)
发自: Web Page
这是UIActionSheet的bug?&&&
想在UIActionSheet中增加不定数量的Button,所以使用addButtonWithTitle方法,动态的增加Button,在Button数量少时一切正常,但当Button数量多之后,显示将要超过一屏时,系统会自动将所有的除Cancel外的Button做成一个可以滚动的列表。OK,列表也没问题,但点击列表里的项时,UIActionSheetDelegate得到的Button Index出问题了,Cancel的index和动态增加的第一个Button的Index都是0,无法区分。 没有办法了,只能自己再做一个View来代替UIActionSheet了。无聊的人可以试试看,希望是我哪里搞错了。
级别: 骑士
UID: 21150
可可豆: 1270 CB
威望: 1221 点
在线时间: 890(时)
发自: Web Page
没有遇到过楼主的这种问题。
级别: 风云使者
可可豆: 54286 CB
威望: 54237 点
在线时间: 1642(时)
发自: Web Page
是bug,但是可以通过手动指定UIActionSheet的cancelbuttonindex来解决
级别: 骑士
可可豆: 1956 CB
威望: 1956 点
在线时间: 385(时)
发自: Web Page
哦,谢谢LS,我试试看
级别: 骑士
可可豆: 1956 CB
威望: 1956 点
在线时间: 385(时)
发自: Web Page
OK,解决了,谢谢yoyokko,代码如下&&&&UIActionSheet *act = [[UIActionSheet alloc] init];&&&&act.delegate =&&&&&&&&for (NSString* menu in _menus) {&&&&&&&&[act addButtonWithTitle:menu];&&&&}&&&&&&&&[act addButtonWithTitle:@&Cancel&;&&&&act.cancelButtonIndex = [_menus count];&&&&&&&&[act showFromToolbar:self.toolbar];&&&&[act release];
级别: 论坛版主
UID: 35043
发帖: 1566
可可豆: 10290 CB
威望: 10290 点
在线时间: 3519(时)
发自: Web Page
回 4楼(qdyl) 的帖子
还在很纠结的判断index?如果只支持iOS4以上的系统的话,是时候试试block了。
关注本帖(如果有新回复会站内信通知您)
iPhone5的分辨率? 正确答案:
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版

我要回帖

更多关于 ipad和iphone同步 的文章

 

随机推荐