2013-06-20 1 views
1

다른 UiView/페이지를 열려면 단추 ("계속")를 만들어야합니다. 나는 아주 새로운 것을 개발하고 있습니다. 누군가 나를 걸어 주실 수 있습니까? 고마워, 너희들은 나를 위해 큰 도움이된다.Storyboard에서 UiActionSheet 사용 하시겠습니까?

코드 :

- (IBAction)OpenActionSheetButton:(id)sender { 


UIActionSheet *actionsheet = [[UIActionSheet alloc]initWithTitle:@"There is no going back,  are you sure???" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Continue" otherButtonTitles:nil, nil]; 
[actionsheet showInView:self.view]; 
} 

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
if(buttonIndex == 0) 
{ 
    UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"storyboardViewIdentifier"]; 
    //storyboardViewIdentifier is the ViewController identifier you specify in the storyboard 

    //PUSH 
    [self.navigationController pushViewController:controller animated:YES]; 
    //Modal 
    [self presentViewController:controller animated:YES completion:Nil]; 
} 
} 

이 내가 코드와 함께했던 것입니다 :

- (IBAction)OpenActionSheetButton:(id)sender { 


UIActionSheet *actionsheet = [[UIActionSheet alloc]initWithTitle:@"There is no going back, are you sure???" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Continue" otherButtonTitles:nil, nil]; 
[actionsheet showInView:self.view]; 
} 

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
if(buttonIndex == 0) 
{ 
    if(buttonIndex == 0) 
     [self performSegueWithIdentifier:@"openView" sender:self]; 
    UIViewController *controller = [self.storyboard 


    instantiateViewControllerWithIdentifier:@"storyboardViewIdentifier"]; 
    //storyboardViewIdentifier is the ViewController identifier you specify in the storyboard 

    //PUSH 
    [self.navigationController pushViewController:controller animated:YES]; 
    //Modal 
    [self presentViewController:controller animated:YES completion:Nil]; 
} 

}

당신의 다음 뷰 컨트롤러를 제기하는 제시의 SEGUE을 수행하지 않는 이유는
+0

은 위아래 시트가 표시됩니까? – ApolloSoftware

+0

네 그렇습니다 :) 그냥 "계속"을 클릭하면, 강제 종료됩니다. – user212803

+2

왜보기 컨트롤러와 현재보기 컨트롤러를 동시에 모달로 밀어야합니까? 하나만 선택해야합니다. –

답변

1

? 스토리 보드로 이동하여 새로운보기 컨트롤러를 가리키는 세그 (segue)를 만듭니다. 모달 세구를 만들어 고유 한 이름을 지정해야합니다.

이렇게하려면 필요한 모든보기 컨트롤러를 스토리 보드에 추가 한 다음 프리젠 테이션 컨트롤러를 마우스 오른쪽 단추로 클릭하십시오. 프리젠 테이션 모달 세구를 만듭니다.

그런 다음 코드에서 당신은 간단하게 넣을 수 있습니다 내부 : 해제

if(buttonIndex == 0) 
     [self performSegueWithIdentifier:@"openView" sender:self]; 

도 쉽게!

[self dismissModalViewControllerAnimated:YES]; 
+0

안녕하세요, 응답 해 주셔서 감사합니다. 승인. 내가이 일을 제대로하고 있는지 말해줘. 액션 시트가있는보기에서 Controll 키를 누른 상태에서 "Continue"단추를 열고 싶은보기로 끌었다. 모델을 잡아 오른쪽으로 "식별자"상자에 "YesContinue"라는 이름을 입력했습니다. "필요한 모든보기 컨트롤러를 스토리 보드에 추가 한 다음보기 컨트롤러를 마우스 오른쪽 단추로 클릭하고 모달 세그먼트보기를 만듭니다."라는 의미를 설명하십시오. 이미 가지고있는 것보다 더 많은 viewcontroller를 추가해야합니까? 고맙다 나는 아주 기본적인 소리지만 나는 : – user212803

+0

나는 내 코드를 업데이트했다. ^^ – user212803