2013-01-21 13 views
0

所以我現在非常沮喪與Objective-C和Xcode現在哈哈...我試圖讓圖像彈出,如果代碼進入,如果聲明,它主要檢查用戶是否在我的遊戲中猜測了單詞中的正確字母(想想hang man)。一旦進入if語句,我想要彈出一個圖像,說明「恭喜!你有50分!」然後移動到在遊戲中的下一個字......我想從一個事件使用UIImageView顯示圖像

,使代碼看起來是這樣的:

if (isWordCompleted) 
{ 
    //do some code that has the pop up image 
    //other stuff as well 
} 

我看了遍計算器,似乎無法得到的答案我」我想找:S

編輯:

if(isWordComplete) 
    { 

     //create an image reference to have pop up congratulating the user for guessing the right answer 
     UIImage *congratsImage = [UIImage imageNamed:@"Congrats.png"]; 
     UIImageView *congratsImageView = [[UIImageView alloc] initWithImage:congratsImage]; 

     [congratsImageView setFrame:CGRectMake(0, 0, 250, 158)]; 
     [myDisplay setHidden:YES]; 
     [myDisplay2 setHidden:YES]; 
     [myDisplay3 setHidden:YES]; 
     [myDisplay4 setHidden:YES]; 
     [myDisplay5 setHidden:YES]; 
     [myDisplay6 setHidden:YES]; 
     [myDisplay7 setHidden:YES]; 
     [self checkNumberofWordsUserCompleteInLevel:isWordComplete]; 
     [self moveToNextWord]; 
} 
+0

在其中查看您所添加的「congratsImageView」? – HRM

回答

0

當你的if語句,然後在執行if語句打開另一個UIView的&的角度提出的

ImageView &也將您的圖像放在ImageView中。或者你也可以嘗試在iPhone中使用PopupView。

將圖像放入Popupview。下面的UIView從工具是圖像: enter image description here

也看到圖像視圖中添加圖像圖片: enter image description here

+0

看到這個鏈接:https://github.com/sonsongithub/PupupView – Vishal

+0

看到這個項目我認爲通過彈出窗口,你可以很容易地得到你想... – Vishal

+0

我不太確定你的意思是UIView ...我不希望使用彈出式視圖 – Stu

相關問題