2012-01-10 3 views
0

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

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]; 

}

Цените помощь в решении этого.

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

ответ

4
[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 не получают каких-либо параметров.

+0

изменилось до сих пор тот же вывод сообщения – user1120133

+0

@ user1120133 Обеспечение точного вывода сообщения и больше вашего кода поможет. – tia

+0

- [UIButton view]: непризнанный селектор отправлен в экземпляр 0x7333bc0 – user1120133

1

@selector(displayModalViewaction) для добавления события;

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

+0

изменил это тоже, но все-таки такое же сообщение выхода – user1120133

+0

теперь работает, но есть разрыв между staus bar и модальным видом – user1120133

Смежные вопросы