음, 단일 레코드의 정보를 표시하는 DetailViewController가있는 RootViewController에 TableView가 있습니다. 상세 페이지에서 나는 멀티미디어 파일을 재생하고 난 프레임 워크 MediaPlayer를 사용하고,이 설명서에 따르면 : 그것은 모든 확인을 보인다 http://www.techotopia.com/index.php/Video_Playback_from_within_an_iOS_4_iPhone_ApplicationNSInvalidArgumentException "MPMoviePlayerController를 사용하여 인스턴스로 전송 된 인식 할 수없는 선택기"
,하지만 난 재생 버튼을 클릭 할 때이 오류가 :
[...]
// Create a table view controller
RootViewController *rootViewController = [[RootViewController alloc]
initWithStyle:UITableViewStylePlain];
rootViewController.managedObjectContext = context;
rootViewController.entityName = @"Porti";
UINavigationController *aNavigationController = [[UINavigationController alloc]
initWithRootViewController:rootViewController];
self.navigationController = aNavigationController;
UIBarButtonItem *homeButton;
homeButton = [[[UIBarButtonItem alloc] initWithTitle:@" Inizio " style:UIBarButtonItemStyleBordered target:self action:@selector(home)] autorelease];
UIBarButtonItem *barButton;
barButton = [[[UIBarButtonItem alloc] initWithTitle:@" Mappa dei porti " style:UIBarButtonItemStyleBordered target:self action:@selector(caricamappa)] autorelease];
[toolbar setItems:[NSArray arrayWithObjects: homeButton, barButton, nil]];
[window addSubview:[navigationController view]];
[window addSubview:toolbar];
[window makeKeyAndVisible];
[rootViewController release];
[aNavigationController release];
:이 탐색 컨트롤러를 사용하는 AppDelegate에에서
:
-[DetailsViewController playmovie]: unrecognized selector sent to instance 0x9117f60 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailsViewController playmovie]: unrecognized selector sent to instance 0x9117f60'
이
내 파일입니다와 I는 DetailViewController에 전달하기 위해 명령어를 사용 RootViewController의 516,:
//Push the new table view on the stack
[self.navigationController pushViewController:detailsView animated:YES];
[detailsView release];
DetailsViewController.h
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import "MLUtils.h"
#import <MediaPlayer/MediaPlayer.h>
@interface DetailsViewController : UIViewController {
IBOutlet UILabel *titleLabel;
IBOutlet UILabel *descriptionLabel;
IBOutlet UIScrollView *descriptionScrollView;
NSString *cityName;
NSString *nomefile;
NSString *extfile;
NSString *description;
}
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *descriptionLabel;
@property (nonatomic, retain) UIScrollView *descriptionScrollView;
@property (nonatomic, retain) NSString *cityName;
@property (nonatomic, retain) NSString *description;
@property (nonatomic, retain) NSString *nomefile;
@property (nonatomic, retain) NSString *extfile;
- (IBAction)playmovie:(id)sender;
@end
이는 본 DetailsViewController.m
이다#import "DetailsViewController.h"
@implementation DetailsViewController
@synthesize titleLabel, descriptionLabel, descriptionScrollView;
@synthesize cityName,description,nomefile, extfile;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
[self.titleLabel setText:self.title];
[self.descriptionLabel setText:self.description];
float textHeight = [MLUtils calculateHeightOfTextFromWidth:self.description : descriptionLabel.font :descriptionLabel.frame.size.width :UILineBreakModeWordWrap];
CGRect frame = descriptionLabel.frame;
frame.size.height = textHeight;
descriptionLabel.frame = frame;
CGSize contentSize = descriptionScrollView.contentSize;
contentSize.height = textHeight;
descriptionScrollView.contentSize = contentSize;
}
-(void)playmovie:(id)sender
{
NSString *appNomeFile = self.nomefile;
NSString *appExtFile = self.extfile;
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:appNomeFile ofType:appExtFile]];
MPMoviePlayerController *moviePlayer =
[[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
if ([moviePlayer
respondsToSelector:@selector(setFullscreen:animated:)])
{
[moviePlayer.view removeFromSuperview];
}
[moviePlayer release];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return YES;
}
- (void)dealloc {
[titleLabel release];
[descriptionLabel release];[descriptionScrollView release];
[cityName release];
[description release];
[nomefile release];
[extfile release];
[super dealloc];
}
@end
제 질문은 : 내 오류는 어디에 있습니까? 나는 그것이 playmovie 메서드의 호출에 있다고 상상하지만 솔루션을 알아낼 수는 없습니다!
P.
실수로 댓글을 삭제했습니다. 너무 죄송합니다. = (
playmovie는 ibaction!입니다. DetailsViewController.h의 의 xib에있는 버튼을 클릭하여 호출합니다. - (IBAction) playmovie : (id) sender; – obithemaster
@obithemaster : 내 편집 – Oliver
젠장, 편집 해주세요! 감사합니다. * ____ * 그냥 이랬어?왜???? O___o 나는 때때로 n00b를 느낀다! – obithemaster