【发布时间】:2012-08-28 08:20:18
【问题描述】:
实际上,我一直在研究如何从块中调用方法。 我正在尝试从 iphone 照片应用程序中获取所有图像。这是代码....
void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
if(group != nil) {
[self.groups addObject:group];
[group enumerateAssetsUsingBlock:selectionBlock];
}
};
[library enumerateGroupsWithTypes:groupTypes
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error) {NSLog(@"A problem occurred");}];
在 selectionBlock ...我只想在用户单击任何图像时添加一个动作。 所以我尝试了这段代码..
[imgView addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
buttonPressed 也在同一个 .m 文件中定义。
- (void) buttonPressed: (id) sender {
UIAlertView* av = [[UIAlertView alloc] initWithTitle:@"Howdy!"
message:@"You tapped me."
delegate:nil
cancelButtonTitle:@"Cool"
otherButtonTitles:nil];
[av show];
}
但是在 selectionBlock 中我得到“'UIImageView' 没有可见的@interface 声明选择器'addTarget:action:forControlEvents'”
我是 iOS 编程新手。所以任何帮助都会非常非常感激!
【问题讨论】:
标签: objective-c ios5 xcode4.3