2013-02-16 21 views
-5

我需要的代碼去代替(label.text等)下面是一個例子:使UIActionSheet轉到另一個視圖的代碼?

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == 0) { 
     self.label.text = @"Destructive Button Clicked"; 
    } else if (buttonIndex == 1) { 
     self.label.text = @"Other Button 1 Clicked"; 
    } 
} 

另外,你能告訴我整個代碼?就像在.h和.m中一樣?我很難搞清楚我是一個noob :(謝謝你們!你已經幫了很多!:)

+0

你有沒有考慮嘗試使用它們之前學習Objective-C和Cocoa Touch的基礎? SO不是免費的代碼工廠。 – 2013-02-16 06:08:42

回答

1

這完全取決於你如何構建應用程序。如果您使用的故事板可以使用:

if (buttonIndex == 0) { 

    UIViewController *controller = [self.storyboard instantiateViewControll:@"storyboardViewName"]; 
    //Push 
    [self.navigationController pushViewController:controller animated:YES]; 
    //Modal 
    [self presentViewController:controller animated:YES]; 

} 

否則,它是:

if (buttonIndex == 0) { 

    UIViewController *controller = [[NewViewController alloc] initWithFrame:self.view.frame]; 
    //Push 
    [self.navigationController pushViewController:controller animated:YES]; 
    //Modal 
    [self presentViewController:controller animated:YES]; 

} 
相關問題