标签: uiactionsheet

iPad上的UIActionSheet未显示取消按钮

我试图显示取消按钮,UIActionSheet但它没有显示,这是一个可接受的行为?请指教.

UIActionSheet *actionSheet = [[UIActionSheet alloc]
          initWithTitle:@"Are you sure you want to clear the cache?"
          delegate:self
          cancelButtonTitle:@"No"
          destructiveButtonTitle:@"Yes"
          otherButtonTitles:nil];

[actionSheet showInView:self.view];  

[actionSheet release];
Run Code Online (Sandbox Code Playgroud)

objective-c uiactionsheet ipad ios4

28
推荐指数
1
解决办法
1万
查看次数

UIAlertController在外部点击时处理解除(IPad)

在iOS8之前,我们使用UIActionSheet来显示警报,现在我们需要使用UIAlertController.

当我们使用UIActionSheet时,我们可以通过将clickedButtonAtIndex与cancelButtonIndex进行比较来轻松处理用户在弹出窗口外点击的情况(这意味着他想要取消操作) - 如果用户确实在弹出窗口外按下了取消按钮索引在这个功能.

我们如何使用新的UIAlertController处理这些情况?我试图使用"完成"块,但它没有任何上下文.有一个简单的方法来处理这个?(除了"保存"某些一般变量中的动作状态).

uiactionsheet ipad ios ios8 uialertcontroller

27
推荐指数
2
解决办法
2万
查看次数

使用6个以上的自定义按钮时,UIActionSheet buttonIndex值是否有问题?

我在iPhone(iOS 4.2)上使用UIActionSheet时发现了一个奇怪的问题.考虑以下代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];

    UIActionSheet *actionSheet = [[UIActionSheet alloc] 
                                  initWithTitle:@"TestSheet" 
                                  delegate:self 
                                  cancelButtonTitle:@"Cancel" 
                                  destructiveButtonTitle:nil 
                                  otherButtonTitles: nil];

    [actionSheet addButtonWithTitle:@"one"];
    [actionSheet addButtonWithTitle:@"two"];
    [actionSheet addButtonWithTitle:@"three"];
    [actionSheet addButtonWithTitle:@"four"];
    [actionSheet addButtonWithTitle:@"five"];
    [actionSheet addButtonWithTitle:@"six"];
    //uncomment next line to see the problem in action
    //[actionSheet addButtonWithTitle:@"seven"];

    [actionSheet showInView:window];
    [actionSheet release];

    return YES;
}
- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"buttonIndex: %d, cancelButtonIndex: %d, firstOtherButtonIndex: %d",
          buttonIndex, 
          actionSheet.cancelButtonIndex, 
          actionSheet.firstOtherButtonIndex);
}
Run Code Online (Sandbox Code Playgroud)

如果启动此应用程序,则操作表将按预期运行.这意味着cancelButtonIndex始终为0,并且正确报告按钮索引.按钮"1"依次为1,依此类推.如果您在添加第七个按钮的行中注释,则操作表会生成一种tableview,并在额外的行上显示取消按钮.如果在这种情况下我按下"one"按钮,则buttonindex变量为0,但cancelButtonIndex也是如此.无法判断用户是否已点击"取消"或"一个"按钮.这似乎不应该是这样的.有人不同意吗?谢谢你的帮助.

iphone uiactionsheet ios

25
推荐指数
2
解决办法
1万
查看次数

最后一个动作表按钮没有被点击

我已经在我的项目使用的actionsheet,当它出现就显示所有的按钮,但最后(第4)按钮不回应我的点击(只有它的一半部分响应)..

我知道它的原因是因为我使用了一个TabBarController而且当前的类位于那个tabbar控制器中......只有那部分动作表响应了哪个位于标签页面....而且我的最后一个按钮是一半以上一半在tabbar顶部

请帮忙

iphone user-interface uitabbarcontroller uiactionsheet

24
推荐指数
1
解决办法
6859
查看次数

从UIView/NSObject类显示UIAlertController

我有,working iOS application 为了support iOS8,我正在取代UIAlertView/UIActionSheet with UIAlertController.

问题:
为了显示UIAlertController,我需要UIViewController类的presentViewController方法.
但是 UIAlertView中是从哪个是类显示器inheritedUIView or NSObject,
我不能[self presentViewController...]为明显的原因的方法.

我的工作:
我尝试获取rootViewController表单当前窗口并显示UIAlertController.

[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController ...]
Run Code Online (Sandbox Code Playgroud)

但有一些旋转问题,如果我的当前视图控制器没有旋转支持,它将旋转,如果UIAlertController打开.

问题:
有没有人遇到同样的问题并且有安全的解决方案?
如果是,请给我一些例子或给一些指导

objective-c uialertview uiactionsheet ios8 uialertcontroller

24
推荐指数
5
解决办法
3万
查看次数

iOS 8 UIActionSheet忽略视图控制器supportedInterfaceOrientations和shouldAutorotate

我有一个通过plist文件配置的应用程序,以支持纵向,横向左和横向右方向(即UISupportedInterfaceOrientations设置为UIInterfaceOrientationPortrait,UIInterfaceOrientationLandscapeLeft和UIInterfaceOrientationLandscapeRight).但是我将支持的方向限制在视图控制器内部.如果我在视图控制器的视图上显示UIActionSheet然后旋转设备,则UIActionSheet将旋转到新方向.这仅发生在运行iOS 8(GM Seed)的设备上.

我希望UIActionSheet遵循包含视图控制器的规则而不是旋转.思考?

我不希望这种情况发生: 截图http://oi58.tinypic.com/20tgto2.jpg

UIViewController示例代码:

- (IBAction)onTouch:(id)sender
{
    UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:@"hi"
                                                       delegate:nil
                                              cancelButtonTitle:@"Cancel"
                                         destructiveButtonTitle:nil
                                              otherButtonTitles:@"Open", nil];

    [actionSheet showInView:self.view];
}

#pragma mark - Rotation methods

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

rotation orientation uiactionsheet ios ios8

24
推荐指数
3
解决办法
9817
查看次数

操作表未在iPad上显示"取消"按钮

在iPhone上,此代码显示取消按钮:

- (IBAction)buttonPressed
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                  initWithTitle:@"Are you sure?"
                                  delegate:self 
                                  cancelButtonTitle:@"No way!"
                                  destructiveButtonTitle:@"Yes, I'm sure!"
                                  otherButtonTitles:nil];
    [actionSheet showInView:self.view];
    [actionSheet release];  
}
Run Code Online (Sandbox Code Playgroud)

但在iPad上,只有破坏性按钮显示.
有什么问题?

iphone uiactionsheet ipad

23
推荐指数
2
解决办法
2万
查看次数

UIActionSheet更改箭头位置?

要在iPad上显示UIActionSheet,我这样做了:

[actionSheetX showFromRect:RectX inView:myView animated:YES];
Run Code Online (Sandbox Code Playgroud)

弹出窗口的箭头指向下方,我可以将此位置更改为指向左侧,上方或右侧,就像使用普通弹出框一样?

uikit uiactionsheet ipad

22
推荐指数
2
解决办法
8768
查看次数

如何在UIDatePicker iphone中只显示时间

在我的应用程序中,我UIDateTimePicker通过代码显示操作表.它工作正常.但我不想显示日期和日期.如何做到这一点.请帮忙.提前致谢.

码:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Select     Date",@"Selecte Date")delegate:self cancelButtonTitle:NSLocalizedString(@"Done",@"Done")
destructiveButtonTitle:NSLocalizedString(@"Cancel",@"Cancel")
otherButtonTitles:nil];  


    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
  UIDatePicker  *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 50, 320, 270)];
    //datePicker.showsSelectionIndicator = YES;
//   datePicker.dataSource = self;
//datePicker.delegate = self;
    [actionSheet addSubview:datePicker];
    [datePicker release];

    [actionSheet showInView:self.view];
    [actionSheet setBounds:CGRectMake(0, 0, 320, 500)];
  [actionSheet release];
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiactionsheet

22
推荐指数
2
解决办法
2万
查看次数

在iOS8中更改操作表弹出箭头

我正在使用UIAlertController.但是在iOS 8的iPad上,actionSheet显示了弹出式箭头.任何隐藏箭头的想法?

这是我的代码:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"this is alert controller" message:@"yeah" preferredStyle:UIAlertControllerStyleActionSheet];

            UIAlertAction *cancelAction = [UIAlertAction
                                           actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel action")
                                           style:UIAlertActionStyleCancel
                                           handler:^(UIAlertAction *action)
                                           {
                                               NSLog(@"Cancel action");
                                           }];

            UIAlertAction *okAction = [UIAlertAction
                                       actionWithTitle:NSLocalizedString(@"OK", @"OK action")
                                       style:UIAlertActionStyleDefault
                                       handler:^(UIAlertAction *action)
                                       {
                                           NSLog(@"OK action");
                                       }];

            UIAlertAction *deleteAction = [UIAlertAction
                                           actionWithTitle:NSLocalizedString(@"Delete", @"Delete action")
                                           style:UIAlertActionStyleDestructive
                                           handler:^(UIAlertAction *action) {
                                               NSLog(@"Delete action");
                                           }];

            [alertController addAction:cancelAction];
            [alertController addAction:okAction];
            [alertController addAction:deleteAction];

            UIPopoverPresentationController *popover = alertController.popoverPresentationController;
            if (popover) {
                popover.sourceView = self.view;
                popover.sourceRect = self.view.bounds;
                popover.permittedArrowDirections = UIPopoverArrowDirectionUnknown;
            } …
Run Code Online (Sandbox Code Playgroud)

uiactionsheet ipad uipopovercontroller ios8 uialertcontroller

21
推荐指数
3
解决办法
2万
查看次数