ios - SGActionView 网格菜单

标签 ios objective-c xcode uialertview uiactionsheet

我正在开发一个应用程序,我在其中使用我从这里下载的网格菜单 https://github.com/sagiwei/SGActionView它工作正常,但我的问题是我不知道当用户从这个网格菜单中点击一个按钮时我将如何显示 nslog。例如,如果用户点击 Facebook,它应该 NSLog “Facebook Pushed”。这是调用网格的代码。

[SGActionView showGridMenuWithTitle:@"Share"
                             itemTitles:@[ @"Facebook", @"Twitter", @"Google+", @"Linkedin",
                                           @"Weibo", @"WeChat", @"Pocket", @"Dropbox" ]
                                 images:@[ [UIImage imageNamed:@"facebook"],
                                           [UIImage imageNamed:@"twitter"],
                                           [UIImage imageNamed:@"googleplus"],
                                           [UIImage imageNamed:@"linkedin"],
                                           [UIImage imageNamed:@"weibo"],
                                           [UIImage imageNamed:@"wechat"],
                                           [UIImage imageNamed:@"pocket"],
                                           [UIImage imageNamed:@"dropbox"]]
                         selectedHandle:nil];

请告诉我从这个网格(facebook、twitter 或任何其他)按下按钮时如何执行操作谢谢

最佳答案

好的,我查了图书馆。

方法原型(prototype)为

+ (void)showGridMenuWithTitle:(NSString *)title
                   itemTitles:(NSArray *)itemTitles
                       images:(NSArray *)images
               selectedHandle:(SGMenuActionHandler)handler

SGMenuActionHandler 是 block 类型。

typedef void(^SGMenuActionHandler)(NSInteger index);

所以你可以这样使用

[SGActionView showGridMenuWithTitle:@"Share"
                         itemTitles:@[ @"Facebook", @"Twitter", @"Google+", @"Linkedin",
                                       @"Weibo", @"WeChat", @"Pocket", @"Dropbox" ]
                             images:@[ [UIImage imageNamed:@"facebook"],
                                       [UIImage imageNamed:@"twitter"],
                                       [UIImage imageNamed:@"googleplus"],
                                       [UIImage imageNamed:@"linkedin"],
                                       [UIImage imageNamed:@"weibo"],
                                       [UIImage imageNamed:@"wechat"],
                                       [UIImage imageNamed:@"pocket"],
                                       [UIImage imageNamed:@"dropbox"]]
                     selectedHandle:^(NSInteger index){

                         if(index == 0){
                         }
                         else if(index == 1){
                         },....

                     }];

正如我对您的原始帖子的评论,我以前从未使用过该库。这只是一个猜测。

关于ios - SGActionView 网格菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25804034/

相关文章:

ios - 获取 MapView.annotations 数组中 MKAnnotation 的索引

objective-c - Objective C 循环中局部变量的优化

iphone - 如何设置tableView的背景颜色

ios - 在键盘显示或隐藏时调整 UIView

ios - Xcode 6 Interface Builder 文件中的未知类 ViewController

objective-c - 正确使用核心数据来多次访问数据 - iphone/ipad

iphone - 核心数据获取

ios - 在 Xcode 中复制文件夹内容

xcode - 创建通用应用程序时,如何链接到32位和64位版本分开的框架?

ios - iOS-UIWebView-URL的奇怪连接