【发布时间】:2013-06-05 22:48:33
【问题描述】:
我正在使用iCarousel Library,但遇到了一些问题。
在控件演示示例项目中,使用了 XIB 文件,视图设置如下:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
if (!view)
{
//load new item view instance from nib
//control events are bound to view controller in nib file
//note that it is only safe to use the reusingView if we return the same nib for each
//item view, if different items have different contents, ignore the reusingView value
view = [[[NSBundle mainBundle] loadNibNamed:@"ItemView" owner:self options:nil] lastObject];
}
return view;
}
因为我使用的是 Storyboard,所以我创建了一个视图控制器并像这样设置视图:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
NSString * storyboardName = @"MainStoryboard";
NSString * viewControllerID = @"DuuinNewsItem";
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
//create new view if no view is available for recycling
if (!view)
{
DUDuuin *tDuuin = [_duuins objectAtIndex:index];
DUNewsItemViewController * controller = (DUNewsItemViewController *)[storyboard instantiateViewControllerWithIdentifier:viewControllerID];
controller.duuin = tDuuin;
view = controller.view;
[view setFrame:CGRectMake(0, 0, 314.0f, 415.0f)];
}
return view;
}
当我向视图中的任何按钮添加操作时,我会收到错误消息:
我尝试了很多 Stackoverflow 中推荐的东西,但我找不到解决方案:
我试过了:
- 将出口设置为强(有人说这是一个问题,因为 ARC)
- 在操作中删除发件人
- 在 View Controller 中添加具有 icarousel 的方法
****更新****
现在我看到了其他问题。当我在 DUNewsItemViewController 中定义 Action 并在模拟器中尝试时,它说:
-[__NSCFType btnTest:]: unrecognized selector sent to instance 0x1577c650
所以,我在 View Controller 的 .m 文件中添加了具有 iCarousel 的方法,问题仍然相同:
EXC_BAD_ACCESS (code=2)
一些信息:
- 我正在使用 ARC
- 故事板上有
- 观看次数是动态的
【问题讨论】:
-
你设置的强势出口是什么?
iCarousel、DUNewsItemViewController或View的插座? -
按钮@Firo的出口
标签: iphone ios delegates icarousel