小编Don*_*hen的帖子

如何使用UIAlertController替换UIActionSheet?

我正在维护一个基于SDK 6.0的旧iOS项目.

这个项目的方法称为

-(void) showComboBox:(UIView*)view:withOptions:(NSDictionary*)options

用于显示组合框.为了实现这一目标,它使用了UIActionSheet,这在iOS8上已弃用.

我的解决方案是这样的:

        if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8) {
        UIAlertController* alertController = [UIAlertController 
           alertControllerWithTitle:@"title" 
           message:@"message" 
           preferredStyle:UIAlertControllerStyleActionSheet];

        UIAlertAction* item = [UIAlertAction actionWithTitle:@"item" 
           style:UIAlertActionStyleDefault 
           handler:^(UIAlertAction *action) {
            //do something here 
            //inform the selection to the WebView 
            ...
            [alertController dismissViewControllerAnimated:YES completion:nil];
        }];

        UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            [alertController dismissViewControllerAnimated:YES completion:nil];
        }];

        [alertController addAction:item];
        [alertController addAction:cancelAction];
        //I am not sure whether it's the right way
        if ([view.nextResponder isKindOfClass:UIViewController.class]) {
            UIViewController* vc = (UIViewController*)view.nextResponder;
            [vc presentViewController:alertController animated:YES completion:nil]; …
Run Code Online (Sandbox Code Playgroud)

objective-c uiactionsheet ios uialertcontroller

51
推荐指数
4
解决办法
5万
查看次数

如何在通知中心删除特定的远程通知

我们都知道这种方法[UIApplication sharedApplication].applicationIconBadgeNumber = 0;可以从通知中心移除我们应用程序的所有远程通知。但是,出于某种原因,我想删除用户点击通知中心的那个,而保留其他的。

它有什么方法可以做到吗?

apple-push-notifications ios

7
推荐指数
2
解决办法
8098
查看次数

HMSegmentedControl如何刷新其标题

我在我的应用程序中使用HMSegmentedControl.我在视图控制器A中创建了一个HMSegmentedControl实例,然后跳转到视图控制器B来收集数据,如下所示: [self presentViewController:vc animated:YES completion:nil];

然后我回去查看控制器A并根据视图控制器B中的值更改了HMSegmentedControl的标题.我曾经setSectionTitles:做过这个工作.在我点击其中一个标题之前标题没有刷新,但我希望它立即刷新.怎么做?

我尝试过self.view setNeedsDisplay但没有奏效.

uicontrol ios

0
推荐指数
1
解决办法
486
查看次数