0

以下のメソッドのAppDelegate.mで1つのViewControllerから1つのViewControllerに時間を設定したため、アプリがクラッシュしました。メッセージが表示されます:インスタンス0x6a0e360に送信された認識されないセレクター。

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self performSelector:@selector(toSecondViewController:) withObject:nil afterDelay:5];
}

-(void)toSecondViewController{
    SecondViewController *second = [[SecondViewController alloc] init];
    [self.navigationController pushViewController:sale animated:YES];
}

どうしてか分かりません ?

4

2 に答える 2

2

コードを変更してみる

[self performSelector:@selector(toSecondViewController:) withObject:nil afterDelay:5];

[self performSelector:@selector(toSecondViewController) withObject:nil afterDelay:5];

func にパラメーターがない場合は、func 名の後に " : " 記号を追加しないでください。

于 2012-09-26T04:34:16.473 に答える
1

パラメータを送信する場合は、「:」を追加する必要があります。それ以外の場合は、追加する必要はありません。

したがって、正しいコードは [self performSelector:@selector(toSecondViewController) withObject:nil afterDelay:5]; です。

于 2012-09-26T05:45:04.317 に答える