2010-09-13 149 views
-3

嗨,大家好,以顯示另一種觀點認爲一個觀點我是新來的iPhone應用程序的開發,請幫我使用按鈕通過點擊按鈕

+0

您是谷歌嗎?或者Atleast是否通過UIViewController類引用?使用「 - (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated」in「On button click」action handler – Satyam 2010-09-13 11:24:25

回答

1

那是一個非常模糊的問題,從一個視圖展現另一種觀點......這裏是一個開始 - 你可以看看一些語法和研究了一下:

這在viewDidLoad中:

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[button setTitle:@"Click" forState:UIControlStateNormal]; 
[button addTarget:self action:@selector(showView) forControlEvents:UIControlEventTouchUpInside]; 
[self.view addSubview:button]; 
[button release]; 

,則此方法

- (void)showView { 
    UIView *view = [[UIView alloc] initWithFrame:CGRect(0,0,320,460)]; 
    [self.view addSubview:view]; 
    [view release]; 
} 

如果你想推一個視圖控制器,那麼你需要查找導航控制器和方法pushViewController:animated:

0

這是通用代碼ü可以使用去下一個視圖或去後面,只要改變按鈕的名稱,其你想按下你想要去的視圖名稱。例如在後退按鈕按u想去庫視圖,然後編寫代碼 -

-(IBAction)backButtonPressed:(id) sender 
{ 
    libraryView *libraryview=[[libraryView alloc] initWithNibName:nil bundle:nil]; 
    libraryview.modalTransitionStyle=UIModalTransitionStyleCoverVertical; 
    [self presentModalViewController:libraryview animated:YES]; 
    [libraryview release]; 
} 

讓我知道烏爾問題是否得到解決或沒有。