我正在使用一個應用程序,當點擊一個視頻文件時需要打開「MPMoviePlayerViewController」。UITextfield在解除presentMoviePlayerViewControllerAnimated後不顯示鍵盤
有一個tabbarController到我們的應用程序,它有四個導航控制器的四個選項卡。
我的應用程序只支持縱向,但視頻應支持橫向&肖像方向。所以,我製作了「MPMoviePlayerViewController」的子類。
那個類的代碼..
@interface MyMovieViewController : MPMoviePlayerViewController
@end
@implementation MyMovieViewController
-(void)viewDidLoad{
[self setWantsFullScreenLayout:NO];
}
-(void)viewWillDisappear:(BOOL)animated{
[self resignFirstResponder];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}
-(BOOL)shouldAutorotate{
return YES;
}
@end
在第一個選項卡中,我告訴畫廊。有一個代碼可以打開視頻文件。
UIGraphicsBeginImageContext(CGSizeMake(1,1));
MPMoviePlayerViewController * vc = [[MyMovieViewController alloc] initWithContentURL:[[[elcAsset asset] valueForProperty:ALAssetPropertyURLs] valueForKey:[[[[elcAsset asset] valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]]];
UIGraphicsEndImageContext();
// Remove the movie player view controller from the "playback did finish" notification observers
[[NSNotificationCenter defaultCenter] removeObserver:vc
name:MPMoviePlayerPlaybackDidFinishNotification
object:vc.moviePlayer];
// Register this class as an observer instead
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(doneButtonClick:)
name: MPMoviePlayerPlaybackDidFinishNotification
object: vc.moviePlayer];
[self presentMoviePlayerViewControllerAnimated:vc];
[vc.moviePlayer prepareToPlay];
[vc.moviePlayer play];
視頻是工作文件。它也支持兩種定位。但是當我切換到另一個選項卡時,沒有文本框顯示鍵盤時單擊它。
請幫忙。感謝提前。