我究竟做错了什么??我总是收到 Thread1: signal SIGBRT error.... 我将 UIView(将其更改为带有文件所有者的 iCarousel)连接到来自 iCarousel 类型的名为 icrousel 的对象及其代表。当我将它与上述所有正在运行的应用程序断开连接时(没有它的真正功能)。
h 文件:
///
///
//
#import <UIKit/UIKit.h>
#import "iCarousel.h"
@interface ViewController : UIViewController <iCarouselDelegate,iCarouselDataSource>
@property (strong, nonatomic) IBOutlet iCarousel *icarousel;
@end
.m 文件:
//
// ViewController.m
// CarouselTry
//
// Created by Assaf Grimberg on 5/2/13.
// Copyright (c) 2013 Assaf Grimberg. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize icarousel;
#pragma mark -
#pragma mark iCarousel methods
-(void)carouselDidScroll:(iCarousel *)carousel{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Carousel Scroll" message:@"YEH" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil, nil];
[alert show];
}
-(void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Item selected" message:[NSString stringWithFormat:@"%d", index] delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil, nil];
[alert show];
}
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return 6;
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 180, 180)];
NSString *imageName = [[NSString alloc]initWithFormat:@"%@%d%@", @"gift", index, @".png"];
[imageView setImage:[UIImage imageNamed:imageName]];
for (UIView *subview in view.subviews) {
[subview removeFromSuperview];
}
[view addSubview:imageView];
return view;
}
- (NSUInteger)numberOfPlaceholdersInCarousel:(iCarousel *)carousel
{
//note: placeholder views are only displayed on some carousels if wrapping is disabled
return 0;
}
- (UIView *)carousel:(iCarousel *)carousel placeholderViewAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
if (view == nil) {
view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
}
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 180, 180)];
NSString *imageName = [[NSString alloc]initWithFormat:@"%@%d%@", @"gift", index, @".png"];
[imageView setImage:[UIImage imageNamed:imageName]];
for (UIView *subview in view.subviews) {
[subview removeFromSuperview];
}
[view addSubview:imageView];
return view;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
icarousel.type = iCarouselTypeLinear;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end