2011-12-26 79 views
1

我正在開發iPad應用程序使用sdk 5和故事板從一個已經工作的iPhone應用程序(用separete xibs開發)。我瞭解故事板的工作方式,但我想用參數推送視圖控制器。按鈕調用logIn2行動如:推視圖控制器與參數使用ios5和故事板

- (IBAction)logIn2: (NSString *)strUser: (NSString *)strPass 
{ 
    userViewController *UserViewController = [[userViewController alloc] initWithNibName:@"userViewController" bundle:nil stringOne:strUser stringTwo:strPass]; 
    //UserViewController.hidesBottomBarWhenPushed = YES; 
    [[self navController] pushViewController:UserViewController animated:YES]; 
} 

這是工作正常,但與SDK 5返回一個錯誤的第一行。如何用參數推送視圖?謝謝。

+1

你得到什麼錯誤信息? – 2011-12-26 14:09:25

+0

錯誤:實例消息的接收方類型'userViewController'沒有用選擇器'initWithNibName:bundle:stringOne:stringTwo:'聲明一個方法[4] – Jaume 2011-12-26 14:11:50

回答

1

從錯誤消息中很明顯,您的UserViewController中沒有聲明initWithNibName:bundle:stringOne:stringTwo:方法。你的UserViewController的外觀如何?

+0

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil stringOne:(NSString *)aStringOne stringTwo:(NSString *)aStringTwo { – Jaume 2011-12-26 14:29:36

1

您是否在.h文件中聲明瞭自定義初始值設定項?否則,只有標準的initWithNibName初始值設定項會被找到,而不是你指定的 - 因此是錯誤信息。

+0

{}聲明它在標頭中是不夠的;還必須在.m中實現它。 – 2011-12-26 18:23:56

相關問題