标签: uiactionsheet

UIPopoverController,UIActionSheet和模态视图控制器的保留/释放模式?

我对以下实例所需的对象所有权模式有些不清楚.当我的UIViewController将弹出控制器,操作表或其他视图控制器呈现为模态时,我是否需要挂起对该子控制器的保留引用,直到它被解除为止?

换句话说,以下几行代码是否有效地"转移"了所有权?

[aPopoverController presentPopoverFromBarButtonItem:someButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];

[anActionSheet showFromBarButtonItem:someButtonItem animated:NO];

[aViewController presentModalViewController:someOtherViewController animated:YES];
Run Code Online (Sandbox Code Playgroud)

有人能指出我关于这个主题的明确文件吗?

iphone uiviewcontroller uiactionsheet uipopovercontroller

14
推荐指数
1
解决办法
8556
查看次数

ios UIActionSheet取消按钮无法正常工作

我有这个问题:这是我的代码:

UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Share the race" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Send with mail" otherButtonTitles:nil];
    popupQuery.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    [popupQuery showInView:self.view];
    [popupQuery release];
Run Code Online (Sandbox Code Playgroud)

一切似乎都没问题,2个按钮显示正确,"发送邮件"按钮没问题,但取消仅在上方抓住点击...这里有一个说明情况的镜头:

错误点击!

我该怎么解决这个问题?

谢谢:)

iphone objective-c cancel-button uiactionsheet ios

13
推荐指数
2
解决办法
5162
查看次数

在iOS 7,SDK 7中UIActionSheet解除后,键盘隐藏并再次显示

我在ViewController中创建了一个UIActionSheet.我还添加了代码来捕获UIKeyboardWillShowNotificationUIKeyboardWillHideNotification通知.

我的问题是当我解雇时,我得到两个通知键盘隐藏并再次显示.有人可以告诉我如何预防这个问题?它只发生在iOS 7中并使用SDK 7构建

更新一些代码:

在viewDidLoad中,我初始化一个按钮,当触摸按钮时,将显示动作表.

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(10, 50, 100, 30);
    [button setTitle:@"Open menu" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonTouched) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];

    UITextView* textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
    [self.view addSubview:textView];
    [textView becomeFirstResponder];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
}

- (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar{
    [searchBar resignFirstResponder];
}

- (void) buttonTouched{
    UIActionSheet* actionSheet = [[UIActionSheet …
Run Code Online (Sandbox Code Playgroud)

keyboard uiactionsheet ios ios7

13
推荐指数
1
解决办法
3653
查看次数

未调用UIAlertAction完成块 - iOS

当用户点击按钮时,我的应用程序中会显示一个带有UIAlertController的iOS应用程序.

这一切都很好,除了一件事,完成块不会因某种原因被调用.

这是我的代码:

// Setup the alert information/type.
UIAlertController *action_view = [UIAlertController alertControllerWithTitle:@"Test title" message:@"test message" preferredStyle:UIAlertControllerStyleActionSheet];

// Create and add the cancel button.
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {

    [action_view dismissViewControllerAnimated:YES completion:^{
        NSLog(@"asdhfgjk");
    }];
}];

// Add the action button to the alert.
[action_view addAction:cancel];

// Present the alert to the user.
[self presentViewController:action_view animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

如果您运行该代码,您将看到解除控制器不会运行的行,并且NSLog它内部的语句也不会.但是,如果你删除NSLog并将完成块设置为nil,那么它确实运行....为什么???

谢谢你的时间,丹.

cocoa-touch objective-c uiactionsheet ios uialertcontroller

13
推荐指数
1
解决办法
7650
查看次数

如何使用UITableView自定义UIAlertController,或者在Pages应用程序中是否有像此UI一样的默认控件?

我想实现UIAlertViewController这样的(参考:Pages和Keynote应用程序):

在此输入图像描述.

我已经实现了一个自定义的tableview,并通过模仿来呈现视图UIAlertViewController.但我无法实现与上面类似的用户界面.有没有可用的默认控制器?

-(void)share:(id)sender
{
    [self setModalPresentationStyle:UIModalPresentationCurrentContext];

    AlertViewController *renameCntrl = [self.storyboard instantiateViewControllerWithIdentifier:AlertTblViewidentifier];
    renameCntrl.optionViewDelegate = self;
    renameCntrl.providesPresentationContextTransitionStyle = YES;
    renameCntrl.definesPresentationContext = YES;
    [renameCntrl setModalPresentationStyle:UIModalPresentationOverCurrentContext];
    [self presentViewController:renameCntrl animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

uitableview uiactionsheet ios uialertcontroller

13
推荐指数
1
解决办法
4743
查看次数

iOS8上不推荐使用UIActionSheet

我想在iOS8上使用UIActionSheet,但它已被弃用,我不知道如何使用更新的方式来使用它...

看到旧代码:

-(void)acoesDoController:(UIViewController *)controller{
    self.controller = controller;
    UIActionSheet *opcoes = [[UIActionSheet alloc]initWithTitle:self.contato.nome delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete" otherButtonTitles:@"other", nil];

    [opcoes showInView:controller.view];
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

    //switch case of the buttons

}
Run Code Online (Sandbox Code Playgroud)

为了说清楚,在这个例子中,在UITableView索引中长按后激活了操作表.

如何以正确的方式实现上面的代码?

objective-c deprecated uiactionsheet ios ios8

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

使用preferredStyle:.ActionSheet更改UIAlertController中取消按钮的颜色

是否可以将取消按钮的颜色更改为红色,我知道我们可以使用破坏性样式

  let cancelActionButton: UIAlertAction = UIAlertAction(title: "Cancel", style: .Destructive) { action -> Void in
            print("Cancel")
        }
Run Code Online (Sandbox Code Playgroud)

但我想分开取消按钮,就像这样 在此输入图像描述

uiactionsheet swift uialertcontroller

13
推荐指数
4
解决办法
6836
查看次数

当你在外面点击它时,如何使用uiactionsheet消失?

如果你在外面点击它,如何让你的uiactionsheet消失?这适用于iPhone.显然,ipad默认这样做(我可能错了).

iphone objective-c uiactionsheet

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

UIActionSheet取消按钮不解除动作表

我有一个UIActionSheet,我正在指定取消按钮但是当它点击时它不会被忽略?

UIActionSheet *actionSheet = [[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Target Complete" otherButtonTitles:nil] autorelease]; 
[actionSheet showInView:self.view];
Run Code Online (Sandbox Code Playgroud)

根据文档,我不需要任何代码,甚至当我尝试实现didCancel委托方法时,它从未调用过?

iphone uiactionsheet ios

12
推荐指数
3
解决办法
9573
查看次数

swift中的UIActionSheet将取消按钮放在iOS 7中

我正在将我的应用程序从目标c重写为Swift,我注意到UIActionSheet在Swift版本中的行为与在obj-c版本中的行为不同.

对象版本

在此输入图像描述

Swift版本

在此输入图像描述

这只是iOS 7上的一个问题,它在iOS 8上运行正常(意味着取消在底部),适用于Swift和Obj-c版本

这是相关的一段代码:

var sheet = UIActionSheet(title: nil, delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil)
sheet.addButtonWithTitle("Camera")
sheet.addButtonWithTitle("Photo Library")
sheet.showInView(self.controller.view)
Run Code Online (Sandbox Code Playgroud)

知道怎么解决吗?

uiactionsheet ios swift

12
推荐指数
1
解决办法
2402
查看次数