2012-09-03 23 views
0

您好任何人都可以幫助我,即時試圖填充我的* URL與選擇器視圖的內容,所以我可以使用選定的選擇器行來鏈接播放選定的視頻。即:如果pickerview顯示「vid 1」,那麼按下標有「play vid」的UIRecbutton會播放vid 1,等等。任何幫助都會非常感激,任何幫助我的人都會自動執行我的心理準備。「如果我贏了彩票, 「列表大聲笑。歡呼法朗試圖填充我的* urL與選擇器視圖的內容

PS:我已經設置了所有的代碼,除了從pickerview到vid播放器的picker view信息之外。默認爲:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Video1" ofType:@"MOV"]]; 

只是爲了給一個路徑名,如果在pickerview行讀取視頻1,視頻2等..怎麼我得到這個信息的pathforresource &已將其默認爲電影類型,即:MOV ,mpeg4。

回答

0

我認爲您正在尋找selectedRowInComponent。它會返回當前在您的選擇器中選擇的行。然後在返回值上運行一個if塊,並從中設置你的url文件名和路徑(實際上,switch對你的選擇器中的很多項目可能會更好)。假設你的UIPickerView中只有1段(如只有一個輪子旋轉,而日期選擇器會有3個段,一個爲一個月,一個爲一天,一個爲一年),你想要的可能是這樣的:

- (IBAction)buttonClicked:(id)sender 
{ 
    NSString *fileName; 
    NSString *fileType; 
    switch ([myPicker selectedRowInComponent:0]) 
    { 
     case 0: 
      fileName = @"Video1"; 
      fileType = @"mov"; 
      break; 
     case 1: 
      fileName = @"Video2"; 
      fileType = @"mpeg4"; 
      break; 
     //more cases here depending on how many items are in your UIPickerView 

     default: 
      break; 

    } 
    NSURL *myURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:fileName ofType:fileType]]; 

    //put in your code to play the video in myURL here 
}