NSInvalidArgumentException "Unrecognized selector geschickt Instanz" (mit MPMoviePlayerController)
Gut, ich habe eine TableView in RootViewController mit einem DetailViewController für die Anzeige der Informationen von den einzelnen Datensatz.
In der Detail-Seite, die ich habe, spielen Sie eine multimedia-Datei und ich bin mit dem Rahmen MediaPlayer, nach diesem guide:
http://www.techotopia.com/index.php/Video_Playback_from_within_an_iOS_4_iPhone_Application
es scheint alles ok, aber wenn ich auf den play-button, den ich diese Fehlermeldung:
-[DetailsViewController playmovie]: unrecognized selector sent to instance 0x9117f60
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailsViewController playmovie]: unrecognized selector sent to instance 0x9117f60'
Diese sind meine Dateien:
In der AppDelegate ich diese navigation controller:
[...]
//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];
und in RootViewController ich diese Anleitung zu übergeben, um den DetailViewController:
//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
und dies ist die 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
Meine Frage ist: wo ist mein Fehler ? Ich kann mir vorstellen es ist der Ruf des playmovie Methode, aber ich kann nicht herausfinden, eine Lösung!
P. S.
Ich habe versehentlich einen Kommentar gelöscht, ich bin so sorry! =(
InformationsquelleAutor obithemaster | 2011-11-16
Du musst angemeldet sein, um einen Kommentar abzugeben.
Scheinen Sie zu rufen
playmovie
auf eine Klasse und nicht auf ein Objekt, oder Sie vergessen haben, geben Sie den param. Wenn Sie uns zeigen, wo Sie es nennen, das könnte helfen.Sowieso, das problem ist, dass Sie wahrscheinlich nicht :
oder
statt :
Hier
oneDetailsViewController
ist einDetailsViewController*
Objekt.BEARBEITEN
Löschen XIB-link, "speichern", und stellen Sie Ihre Verbindung wieder auf die IBAction durch ziehen (rechts-Klick) aus-Taste, um den file ' s owner.
siehe mein edit
verdammt, es funktioniert! danke!!! ____ war es nur das?warum???? O___o ich fühle mich wirklich ein n00b manchmal!
Ich habe das gleiche problem viele Male, also jetzt... ich weiß 🙂 Sie haben vielleicht verknüpft Sie die Taste, und änderte dann den Namen der Methode/params. Also XCode ist verloren, aber Sie können visuell sehe es immer... nicht vergessen zu akzeptieren, wenn die Antwort es hat dir geholfen 😉
Getan, danke! =)
InformationsquelleAutor Oliver