UIButton view нераспознанный селектор, отправленный на экземпляр - PullRequest
0 голосов
/ 10 января 2012

В основном у меня есть UIToolbar в главном окне, и когда я нажимаю информационную кнопку, чтобы открыть модальное представление, приложение вылетает с выходным сообщением, что UIButton view нераспознанный селектор отправляется экземпляру.Может кто-нибудь, пожалуйста, помогите мне решить это выходное сообщение.

 UIButton *infoItem =  [[UIButton buttonWithType:UIButtonTypeInfoLight] retain];
                      infoItem.frame = CGRectMake(250.0, 8.0, 25.0, 25.0);
                      infoItem.backgroundColor = [UIColor clearColor];
  [infoItem addTarget:self action:@selector(displayModalViewaction:) forControlEvents:UIControlEventTouchUpInside];
                       infoItem.backgroundColor = [UIColor grayColor];


 UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] 
                             initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
                             target:nil
                             action:nil];


 NSArray *toolbarItems = [NSArray arrayWithObjects: settingsButton, flexItem, systemItem, flexItem, systemItem1,flexItem, systemItem2, flexItem, systemItem3, flexItem, infoItem, nil];

    [toolbar setItems:toolbarItems];



[settingsButton release];
[systemItem  release];
[systemItem1 release];
[systemItem2 release];
[systemItem3 release];
[infoItem release];
[flexItem release];

[super viewDidLoad];


- (void) playaudio: (id) sender {

// Get the file path to the song to play.

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"theme" 
                                                     ofType:@"mp3"];

// Convert the file path to a URL.

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];

//Initialize the AVAudioPlayer.

self.audioPlayer = [[AVAudioPlayer alloc] 
                    initWithContentsOfURL:fileURL error:nil];

// Making sure the audio is at the start of the stream.

self.audioPlayer.currentTime = 0;

[self.audioPlayer play];
}

- (void)pause: (id)sender {

    if

([audioPlayer isPlaying])

{[audioPlayer pause];} 

else 

{[audioPlayer play];}

}

- (void)stop: (id) sender

 {
     [audioPlayer stop];

  }

  - (void)displayModalViewaction 
  {

self.viewController = [[Infoviewcontroller alloc] init];

UINavigationController *navigationController=[[UINavigationController alloc] init];

navigationController.navigationBar.tintColor = [UIColor brownColor];  

[navigationController pushViewController:_viewController animated:YES];

[self.view addSubview:navigationController.view];

}

Благодарим вас за помощь.

Заранее спасибо.

Ответы [ 2 ]

4 голосов
/ 10 января 2012
[infoItem addTarget:self action:@selector(displayModalViewaction:) forControlEvents:UIControlEventTouchUpInside];
                   infoItem.backgroundColor = [UIColor grayColor];

должно быть

[infoItem addTarget:self action:@selector(displayModalViewaction) forControlEvents:UIControlEventTouchUpInside];
                   infoItem.backgroundColor = [UIColor grayColor];

, поскольку displayModalViewaction не получает никаких параметров.

1 голос
/ 10 января 2012

используйте @selector(displayModalViewaction) для добавления события;

или измените метод определения с помощью: - (void)displayModalViewaction:(id)sender;

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...