2012-10-12 70 views
0

我已經添加了UIView,在UIImageView上使用UIBuider, 現在我想在該imageView上應用動畫,所以我拍攝了一組圖像&,添加了使用UIBuider 創建 通過此代碼我想在UIImageView上應用動畫

NSArray *animationArray=[[NSArray alloc]init]; 
     animationArray=[NSArray arrayWithObjects: 
         [UIImage imageNamed:@"rabbit1.png"], 
         [UIImage imageNamed:@"rabbit2.png"], 
         [UIImage imageNamed:@"rabbit3.png"], 
         [UIImage imageNamed:@"rabbit4.png"], 
         [UIImage imageNamed:@"rabbit5.png"], 
         [UIImage imageNamed:@"rabbit6.png"], 
         [UIImage imageNamed:@"rabbit7.png"], 
         [UIImage imageNamed:@"rabbit8.png"], 
         [UIImage imageNamed:@"rabbit9.png"], 
         [UIImage imageNamed:@"rabbit10.png"], 
         [UIImage imageNamed:@"rabbit11.png"], 
         [UIImage imageNamed:@"rabbit12.png"], 
         [UIImage imageNamed:@"rabbit13.png"], nil]; 



     tempImageView.animationImages=animationArray; 
     tempImageView.animationDuration=2; 
     tempImageView.animationRepeatCount=0; 
     [tempImageView startAnimating]; 

tempImageView陣列的ImageView但它不是沃金,沒有顯示任何東西。

+0

你確認爲IBOutlet中tempImageView連接在xib – AppleDelegate

+0

是的它連接 – Rais

+0

我添加了UIImageView使用UIBuider&做一些代碼,沒有人認爲,這是錯的嗎? – Rais

回答

0

似乎在故事板自動layout..i發現同樣沒有結果的錯誤..

通過代碼這個作品試試吧..

mainImageView = [[UIImageView alloc]init]; 
    NSArray *animationArray = [[NSArray alloc]init]; 
    animationArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"first.png"],[UIImage imageNamed:@"second.png"],[UIImage imageNamed:@"first.png"],[UIImage imageNamed:@"second.png"],[UIImage imageNamed:@"first.png"],[UIImage imageNamed:@"second.png"],[UIImage imageNamed:@"first.png"],[UIImage imageNamed:@"second.png"],[UIImage imageNamed:@"first.png"],[UIImage imageNamed:@"second.png"], nil]; //add your images here 

    [mainImageView setFrame:CGRectMake(50,50,100,100)]; 
    mainImageView.animationImages = animationArray; //mainImageView is imageview 
    mainImageView.animationDuration = 2; 
    mainImageView.animationRepeatCount = 0; 
    [mainImageView startAnimating]; 


     [self.view addSubview:mainImageView];