标签: uiactionsheet

在UIActionSheet中添加UIPickerView时,iOS 7上的上下文错误无效?

我在UIActionSheet中有一个UIPickerView,并且在SO的许多其他人建议的方式做到了这一点:

在操作表中添加UIPickerView和按钮 - 如何?

如何在UIActionSheet中添加UIPickerView

直到现在,在iOS 7上测试我的应用程序时,这些解决方案运行良好.它仍然有效,但在Xcode的运行时期间我收到了很多"无效的上下文0x0"警告.

这些错误也带来了一个很好的消息:

CGContextSetFillColorWithColor:无效的上下文0x0.这是一个严重的错误.该应用程序或其使用的库正在使用无效的上下文,从而导致系统稳定性和可靠性的整体降低.此通知是礼貌的:请解决此问题.它将成为即将到来的更新中的致命错误.

可能是Apple最终想要停止这种解决方案,还是我们可以解决或修复的问题?

iphone uipickerview uiactionsheet ios ios7

9
推荐指数
2
解决办法
9700
查看次数

子类化UIAlertController

在iOS 8之前,我们不得不使用UIAlertViewUIActionSheet

我们不允许在它们上面混淆视图层次结构或子类.

UIAlertView 文档

UIAlertView类旨在按原样使用,不支持子类化.此类的视图层次结构是私有的,不得修改.

UIActionSheet 文档

UIActionSheet不是设计为子类,也不应该为其层次结构添加视图.如果您需要提供比UIActionSheet API提供的更多自定义的工作表,您可以创建自己的工作表并使用presentViewController以模态方式呈现它:animated:completion:.

然而,iOS8 Apple已经推出UIAlertController了更换两者UIAlertViewUIActionSheet(请查看此处的预发布文档).

因此,在这个预发布文档中,没有任何关于无法子类化或更改视图层次结构,它甚至有这种方法,addTextFieldWithConfigurationHandler:因此我们能够更改视图层次和/或子类,UIAlertController而不必担心Apple是否会批准或拒绝我们的应用程序?

objective-c uialertview uiactionsheet uialertcontroller

9
推荐指数
2
解决办法
7672
查看次数

是否可以编辑UIAlertAction标题字体大小和样式?

现在iOS8上的过时UIActionsheetUIAlertview定制上iOS7工作不发生作用了.到目前为止,我所知道的唯一定制是色彩.我需要的是改变标题的字体大小和样式,我没有找到任何方式使用新的UIAlertAction.

已经提到了这个,但我仍然希望有一种方法可以至少改变标题大小和字体.

为您提供我的一些代码 UIAlertAction

UIAlertController * alertActionSheetController = [UIAlertController alertControllerWithTitle:@"Settings"
                                                                              message:@""
                                                                       preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction * aboutTheAppAction = [UIAlertAction actionWithTitle:@"About the App"
                                                                 style:UIAlertActionStyleDefault
                                                               handler:^(UIAlertAction * action){
                                                                   NSLog(@"About the app");
                                                                   [self openAbout];

                                                               }];


[alertActionSheetController addAction:aboutTheAppAction];
[self presentViewController:alertActionSheetController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

objective-c uialertview uiactionsheet ios ios8

9
推荐指数
1
解决办法
8808
查看次数

iOS 8仅使用UIAlertController或UIActionSheet进行内存泄漏

当我使用UIActionSheet或UIAlertController执行以下操作时,我在模拟器中看到iOS 8中的内存泄漏.UIActionSheet在IOS 8中使用UIAlertController,因此问题是相关的.

按下按钮时会调用showCameraAction.我已从委托方法中删除了所有内容,但在下面显示的情况下仍然会出现泄漏.我是否以某种方式使用UIActionSheet,我不应该这样做?我将非常感谢您解决此问题的任何帮助.相同的代码与IOS 7没有泄漏(在模拟器中).

-(IBAction)showCameraAction:(id)sender
{

UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:@"Photo From:"
                                                         delegate:self
                                                cancelButtonTitle:@"Cancel"
                                           destructiveButtonTitle:nil
                                                otherButtonTitles:@"Phone", @"Flickr", nil];

[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
//also tried  just showInView: self.view
}
Run Code Online (Sandbox Code Playgroud)

//空

 - (void)actionSheet:(UIActionSheet *)actionSheet
 clickedButtonAtIndex:(NSInteger)buttonIndex {
 }
Run Code Online (Sandbox Code Playgroud)

也尝试使用UIAlertController,结果相同:

UIAlertController *alertController = [UIAlertController
                                      alertControllerWithTitle:@"Photo From:"
                                      message:@""
                                      preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *phoneAction = [UIAlertAction
                               actionWithTitle:NSLocalizedString(@"Phone", @"Phone action")
                               style:UIAlertActionStyleCancel
                               handler:^(UIAlertAction *action)
                               {
                                   NSLog(@"Phone action");
                               }];

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

[alertController addAction:phoneAction];
[alertController addAction:flickrAction];


[self presentViewController:alertController …
Run Code Online (Sandbox Code Playgroud)

memory-leaks uiactionsheet ios ios8 uialertcontroller

9
推荐指数
2
解决办法
4712
查看次数

iPad UIActionSheet没有显示

我使用这篇文章中的代码在我的应用程序中显示一个操作表.但它表现得像

在此输入图像描述

会是什么原因?

我显示操作表的代码是

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                                                         delegate:nil
                                                cancelButtonTitle:nil
                                           destructiveButtonTitle:nil
                                                otherButtonTitles:nil];

[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

CGRect pickerFrame = CGRectMake(0, 40, 300, 300);

UIView *pickerView = [[UIView alloc] initWithFrame:pickerFrame];
pickerView.backgroundColor=[UIColor blackColor];

[actionSheet addSubview:pickerView];


UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
closeButton.momentary = YES; 
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];


[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];

[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];

[self.view addSubview:actionSheet];
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch uiactionsheet

8
推荐指数
1
解决办法
3775
查看次数

更改UIActionSheet标题字符串的字体类型和大小

我有一个标题字符串为"DO:这些任务"的UIActionSheet.在标题字符串中,子字符串"DO:"应该是粗体(具有特定的字体大小),子字符串"这些任务"应该是常规的.可能吗?我怎样才能做到这一点?

iphone font-size uiactionsheet ios

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

如何为Twitter /行动表制作社交分享例外?

我使用以下代码在我的应用程序中调用操作表共享:

- (IBAction)sendPost:(id)sender
{
    NSArray *activityItems = nil;
    UIImage *appIcon = [UIImage imageNamed:@"appIcon.png"];
    NSString *postText = [[NSString alloc] initWithFormat:@"LETS ASSUME THIS STRING IS LONGER THAN 140 CHARACTERS THAT TWITTER PROHIBITS BUT CAN STILL BE SHARED VIA FACEBOOK, EMAIL, TEXT"];
    activityItems = @[postText,appIcon];
    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
    [self presentViewController:activityController animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

问题是这个:postText超过140个字符,所以不可能通过twitter分享,字符数将是-x(你通过twitter分享的红色字符数),我的问题是:怎么能我做了一个例外,以便shortPostText在选择Twitter进行共享时使用的是另一条消息吗?

一旦你sendPost发送了动作,我就看不到为twitter明确设置字符串的方法了:

在此输入图像描述

编辑:我不明白为什么有人会对这个问题进行投票,我不会问如何制作if/else语句或如何编程.这是一个真正的问题,需要一个真正的答案.

更新:我需要解决这个问题,因为当用户尝试通过我的应用程序中的Twitter共享时,这是我得到的:

在此输入图像描述

红色/负号字符指示符和非活动帖子按钮,因此除非字符数减少到0或更少,否则不允许帖子转到twitter.

twitter objective-c uiactionsheet ios social-framework

8
推荐指数
1
解决办法
1059
查看次数

更改UIAlertview和UIActionsheet按钮的色调颜色

我正在尝试为iOS 7调整我的应用程序.我遇到的问题是我无法更改某些控件的色调颜色.

我添加了

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
if (IOS7_OR_LATER)
    self.window.tintColor = [self greenTintColor];
Run Code Online (Sandbox Code Playgroud)

到我的应用代表的

           - (BOOL)application:(UIApplication *)application
 didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Run Code Online (Sandbox Code Playgroud)

它主要有所帮助,但消息框和操作表按钮的颜色仍然是默认的蓝色.

我怎样才能重新着色所有这些按钮呢?

一些截图:

iOS7留言框 iOS7操作表

cocoa-touch objective-c uialertview uiactionsheet ios

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

iPad UIActionSheet - 不显示上次添加的按钮

我正试图在UIActionSheetiPad 上显示一个.这是我正在使用的代码:

-(void) presentMenu {
    UIActionSheet *popupMenu = [[UIActionSheet alloc] initWithTitle:@"Menu" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:nil];
    for (NSString *option in _menuItems) {
        [popupMenu addButtonWithTitle:option];
    }
    popupMenu.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        [popupMenu showFromTabBar:_appDelegate.tabBar.tabBar];
    }
    else if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        [popupMenu showFromBarButtonItem:self.navigationItem.rightBarButtonItem animated:YES];
    }
    [popupMenu release];
    return;
}
Run Code Online (Sandbox Code Playgroud)

该程序的iPhone版本显示所有按钮_menuItems,但iPad版本只是忽略该阵列中的最后一项.有谁知道为什么会发生这种情况?

谢谢,
Teja.

objective-c uiactionsheet ipad

7
推荐指数
1
解决办法
978
查看次数

UIPopoverPresentationController:barButtonItem(iPad)上的ActionSheet位置

我在iPhone上有一个UIAlertController(UIAlertControllerStyleActionSheet)现在应该UIPopoverPresentationController在iPad版本上呈现..

我正在做以下事情:

UIPopoverPresentationController *popover = sectionActionSheet.popoverPresentationController;
if (popover){
    popover.sourceView = self.view;
    popover.barButtonItem = menuButton;
    popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,popover的位置(相对于UIBarButton)并不是那么好,如果我旋转设备,弹出窗口不会重新定位:

角落不居中: 在此输入图像描述

旋转后: 在此输入图像描述

uiactionsheet ipad ios uipopover

7
推荐指数
0
解决办法
603
查看次数