码迷,mamicode.com
首页 > 其他好文 > 详细

使用第三方的支持Block 的UIAlertView

时间:2015-06-10 15:43:09      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:pods   block   uialertvie   

github 网址:

https://github.com/jivadevoe/UIAlertView-Blocks

使用

在Pods的Podfile里加入:

pod ‘UIAlertView-Blocks‘, ‘~> 1.0‘

运行命令:

pod update

代码

RIButtonItem *cancelItem = [RIButtonItem itemWithLabel:@"No" action:^{
    // this is the code that will be executed when the user taps "No"
    // this is optional... if you leave the action as nil, it won‘t do anything
    // but here, I‘m showing a block just to show that you can use one if you want to.
}];

RIButtonItem *deleteItem = [RIButtonItem itemWithLabel:@"Yes" action:^{
    // this is the code that will be executed when the user taps "Yes"
    // delete the object in question...
    [context deleteObject:theObject];
}];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Delete This Item?"
                                                    message:@"Are you sure you want to delete this really important thing?"
                                           cancelButtonItem:cancelItem
                                           otherButtonItems:deleteItem, nil];
[alertView show];

也可以初始化后添加按钮

[alertView addButtonItem:deleteItem];

其它问题

我在使用时,提示:
技术分享

ld: library not found for -lPods-UIAlertView-Blocks
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(null): Library not found for -lPods-UIAlertView-Blocks
(null): Linker command failed with exit code 1 (use -v to see invocation)

处理方法:
把项目和Pods的Architectures设置一致:
技术分享

在Podfile里加入:

post_install do |installer| installer.project.targets.each do |target| target.build_configurations.each do |config| config.build_settings[‘ARCHS’] = “armv7” end end end

使用第三方的支持Block 的UIAlertView

标签:pods   block   uialertvie   

原文地址:http://blog.csdn.net/xundh/article/details/46431725

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!