解决方案 »

  1.   

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
        //导航栏
        self.navigationItem.title=@"BookShelf Demo";
        
        //背景图片设置
        UIImage *backgroundImage=[UIImage imageNamed:@"bg_cork.png"];
        UIColor *backgroundColor=[UIColor colorWithPatternImage:backgroundImage];
        [self.ImageView setBackgroundColor:backgroundColor];
        [self.view insertSubview:self.ImageView aboveSubview:0];    //编辑按钮
        self.navigationItem.leftBarButtonItem=self.editButtonItem;
        
        
        
        //大小and位置
        bookimage[0]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65, 93, 114)];
         bookimage[0].image = [UIImage imageNamed:@"A1.jpeg"];
        //图片显示
        bookimage[0].hidden=NO;
        //点击事件
        bookimage[0].userInteractionEnabled=YES;
        UITapGestureRecognizer *click0=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[0] addGestureRecognizer:click0];
        [self.ImageView addSubview:bookimage[0]];
         NSLog(@"A1");
        [bookimage[0] release];
            
        
        
        
        bookimage[1]=[[UIImageView alloc]initWithFrame:CGRectMake(114, 65, 93, 114)];
        bookimage[1].image = [UIImage imageNamed:@"A2.jpeg"];
        bookimage[1].hidden=NO;
        bookimage[1].contentMode=UIViewContentModeScaleToFill;
        bookimage[1].userInteractionEnabled=YES;
        UITapGestureRecognizer *click1=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[1] addGestureRecognizer:click1];
        [self.ImageView addSubview:bookimage[1]];
        [bookimage[1] release];
        
        
        
        bookimage[2]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65, 93, 114)];
        bookimage[2].image = [UIImage imageNamed:@"A3.jpeg"];
        bookimage[2].hidden=NO;
        bookimage[2].contentMode=UIViewContentModeScaleToFill;
        bookimage[2].userInteractionEnabled=YES;
        UITapGestureRecognizer *click2=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[2] addGestureRecognizer:click2];
        [self.ImageView addSubview:bookimage[2]];
        [bookimage[2] release];
        
        
        bookimage[3]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65+114+12, 93, 114)];
        bookimage[3].image = [UIImage imageNamed:@"A4.jpeg"];
        bookimage[3].hidden=NO;
        bookimage[3].contentMode=UIViewContentModeScaleToFill;
        bookimage[3].userInteractionEnabled=YES;
        UITapGestureRecognizer *click3=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[3] addGestureRecognizer:click3];
        [self.ImageView addSubview:bookimage[3]];
        [bookimage[3] release];
        
        
        
        bookimage[4]=[[UIImageView alloc]initWithFrame:CGRectMake(114,65+114+14 , 93, 114)];
        bookimage[4].image = [UIImage imageNamed:@"A5.jpeg"];
        bookimage[4].hidden=NO;
        bookimage[4].contentMode=UIViewContentModeScaleToFill;
        bookimage[4].userInteractionEnabled=YES;
        UITapGestureRecognizer *click4=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[3] addGestureRecognizer:click4];
        [self.ImageView addSubview:bookimage[4]];
        [bookimage[4] release];
        
        bookimage[5]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65+114+14, 93, 114)];
        bookimage[5].image = [UIImage imageNamed:@"A6.jpeg"];
        bookimage[5].hidden=NO;
        bookimage[5].contentMode=UIViewContentModeScaleToFill;
        bookimage[5].userInteractionEnabled=YES;
        UITapGestureRecognizer *click5=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[3] addGestureRecognizer:click5];
        [self.ImageView addSubview:bookimage[5]];
        [bookimage[5] release];
        
        bookimage[6]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65+(114+14)*2, 93, 114)];
        bookimage[6].image = [UIImage imageNamed:@"A7.jpeg"];
        bookimage[6].hidden=NO;
        bookimage[6].contentMode=UIViewContentModeScaleToFill;
        bookimage[6].userInteractionEnabled=YES;
        UITapGestureRecognizer *click6=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[6] addGestureRecognizer:click6];
        [self.ImageView addSubview:bookimage[6]];
        [bookimage[6] release];
        
        bookimage[7]=[[UIImageView alloc]initWithFrame:CGRectMake(112, 65+(114+14)*2, 93, 114)];
        bookimage[7].image = [UIImage imageNamed:@"A8.jpeg"];
        bookimage[7].hidden=NO;
        bookimage[7].contentMode=UIViewContentModeScaleToFill;
        bookimage[7].userInteractionEnabled=YES;
        UITapGestureRecognizer *click7=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[7] addGestureRecognizer:click7];
        [self.ImageView addSubview:bookimage[7]];
        [bookimage[7] release];
        
        bookimage[8]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65+(114+14)*2, 93, 114)];
        bookimage[8].image = [UIImage imageNamed:@"A9.jpeg"];
        bookimage[8].hidden=NO;
        bookimage[8].contentMode=UIViewContentModeScaleToFill;
        bookimage[8].userInteractionEnabled=YES;
        UITapGestureRecognizer *click8=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[8] addGestureRecognizer:click8];
        [self.ImageView addSubview:bookimage[8]];
        [bookimage[8] release];
        
        bookimage[9]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65+(114+14)*3, 93, 114)];
        bookimage[9].image = [UIImage imageNamed:@"A10.jpeg"];
        bookimage[9].hidden=NO;
        bookimage[9].contentMode=UIViewContentModeScaleToFill;
        bookimage[9].userInteractionEnabled=YES;
        UITapGestureRecognizer *click9=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[9] addGestureRecognizer:click9];
        [self.ImageView addSubview:bookimage[9]];
        [bookimage[9] release];
        
        
        bookimage[10]=[[UIImageView alloc]initWithFrame:CGRectMake(112,65+(114+14)*3, 93, 114)];
        bookimage[10].image = [UIImage imageNamed:@"A11.jpeg"];
        bookimage[10].hidden=NO;
        bookimage[10].contentMode=UIViewContentModeScaleToFill;
        bookimage[10].userInteractionEnabled=YES;
        UITapGestureRecognizer *click10=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[10] addGestureRecognizer:click10];
        [self.ImageView addSubview:bookimage[10]];
        [bookimage[10] release];
        
        bookimage[11]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65+(114+14)*3, 93, 114)];
        bookimage[11].image = [UIImage imageNamed:@"A12.jpeg"];
        bookimage[11].hidden=NO;
        bookimage[11].contentMode=UIViewContentModeScaleToFill;
        bookimage[11].userInteractionEnabled=YES;
        UITapGestureRecognizer *click11=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
        [bookimage[11] addGestureRecognizer:click11];
        [self.ImageView addSubview:bookimage[11]];
        [bookimage[11] release];
    }
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    -(void)setEditing:(BOOL)editing animated:(BOOL)animated
    {
        [super setEditing:editing animated:animated];
        if(editing)
        {
            NSLog(@"编辑状态");
        }else
        {
            NSLog(@"非编辑状态");
        }
    }//内存释放
    - (void)dealloc {    [_ImageView release];
        [super dealloc];
    }
    @end