2012-01-09 3 views
0

가능한 중복은 :
Is there anyway to add same scroll menubar at the navigation bar?어떻게 여러 개의보기 컨트롤러에서 동일한 버튼을 만들 수 있습니까?

은 바보 같은 질문 일지 모르지만 it.My 질문에 따라 내 전체 프로젝트이기 때문에 나는, 어떤 희생을 치르더라도 그것을 해결하기 위해

I가 네보기 제어기 A, B, C, D.

A는 4 개 버튼 인 btn1있다 , btn2, btn3, brn4. 내가 btn을 클릭 할 때

btn1 클릭 -> 컨트롤러 리로드 또는 현재 컨트롤러 리로드;

btn2 클릭 -> B 컨트롤러 열기;

btn3 클릭 -> C 컨트롤러 열기;

btn4 클릭 -> D 컨트롤러 열기;

B에는 btn1, btn2, btn3, brn4의 4 가지 버튼이 있습니다.입니다. 내가 btn을 클릭하면 시작됩니다.

btn1 클릭 -> 컨트롤러가 열림;

btn2 클릭 -> B 컨트롤러 다시로드 또는 현재 컨트롤러 다시로드.

btn3 클릭 -> C 컨트롤러 열기;

btn4 클릭 -> D 컨트롤러 열기;

C에는 4 개의 버튼 btn1, btn2, btn3, brn4이 있습니다. 내가 btn을 클릭하면 시작됩니다.

btn1 클릭 -> 컨트롤러가 열림;

btn2 클릭 -> B 컨트롤러 열기;

btn3 클릭 -> C 컨트롤러 다시로드 또는 현재 컨트롤러 새로 고침.

btn4 클릭 -> D 컨트롤러 열기;

D에는 4 개의 버튼 btn1, btn2, btn3, brn4이 있습니다. 내가 btn을 클릭하면 시작됩니다.

btn1 클릭 -> 컨트롤러가 열림;

btn2 클릭 -> B 컨트롤러 열기;

btn3 클릭 -> C 컨트롤러 열기;

btn4 클릭 -> D 컨트롤러 새로 고침 또는 현재 컨트롤러 새로 고침.

어떻게 처리해야합니까?

감사의 말 전진.

EDIT :

내 이러한 제어기 (A는 B, C, D)이 TabBar의 컨트롤러에있는 버튼을 controller.I의 상단되어있는 ScrollView에 모든 이미지를 부착 한 이러한 UI로, 지금까지 내가 더 이상 질의가 물어 주시기 바랍니다 ....

enter image description here

이런 짓을했는지. 다시 한번 감사

편집 2 :

이 내가 tabbar 항목의 모든 컨트롤러 viewDidload에서 가져온 버튼의있는 ScrollView입니다. 여기

scrollButtonView = [[scrollViewButtons alloc] initWithNibName:@"scrollViewButtons" bundle:nil]; 
CGRect frame = CGRectMake(0, 20, 320, 43); 
scrollButtonView.view.frame = frame; 
scrollButtonView.view.userInteractionEnabled =YES; 
[self.navigationController.view addSubview:scrollButtonView.view]; 

내가 버튼 click.but 문제의 컨트롤러를 전환 할 코드 나 그 가져올 때, B는 C가 D가 그때 오류를 발견된다 Unknown controller

-(void)mybuttons:(id)sender{ 
NSLog(@"mybuttons called"); 
UIButton *button=(UIButton *)sender; 
if (button.tag == 0) { 
    NSLog(@"hey have clicked first button, this is my tag : %i \n\n",button.tag); 
    [button setBackgroundImage:[UIImage imageNamed:@"btn_topmenu_hover.png"] forState:UIControlStateSelected]; //sets the background Image] 
} 
else { 
    [button setBackgroundImage:[UIImage imageNamed:@"btn_topmenu_normal.png"] forState:UIControlStateNormal]; //sets the background Image] 

} 
if (button.tag == 1) { 
    NSLog(@"hey have clicked second button, this is my tag : %i \n\n",button.tag); 
    [button setBackgroundImage:[UIImage imageNamed:@"btn_topmenu_hover.png"] forState:UIControlStateNormal]; //sets the background Image] 
    self.tabBarController.selectedIndex = 1; 
} 
else if (button.tag == 2) { 
    NSLog(@"hey have clicked first button, this is my tag : %i \n\n",button.tag); 
    [button setBackgroundImage:[UIImage imageNamed:@"btn_topmenu_hover.png"] forState:UIControlStateNormal]; //sets the background Image] 

    //UIViewController *newController = [[UIViewController alloc] initWithNibName:@"CustomerViewController" bundle:nil]; 
    //UINavigationController *myCustomerController = [[[UINavigationController alloc] initWithRootViewController:newController] autorelease]; 
    //UINavigationController *myCustomerController = [[UINavigationController alloc] initWithNibName:@"CustomerViewController" bundle:nil]; 
    UIViewController *secondViewController = [[UIViewController alloc] initWithNibName:@"CustomerViewController" bundle:nil]; 
    [self.navigationController pushViewController:secondViewController animated:YES]; 
    self.tabBarController.selectedIndex = 2; 
} 
else if (button.tag == 3) { 
    NSLog(@"hey have clicked second button, this is my tag : %i \n\n",button.tag); 
     [button setBackgroundImage:[UIImage imageNamed:@"btn_topmenu_hover.png"] forState:UIControlStateNormal]; //sets the background Image] 
     //[self.navigationController pushViewController:cstViewController animated:YES]; 
     self.tabBarController.selectedIndex = 3; 
    } 
    } 

EDIT3 :

나는 어떤 방식 으로든 문제를 해결해야하므로 어떤 방식 으로든 시도했지만 간단한 문제가 생겼다. 내가 수돗물 바를 바꾸고 싶을 때이 단추를 얻는다면이 문제를 조금 다른 방식으로 해결할 수 있습니다. 대답을 보면 대답을 얻을 수 있습니다 ..

질문이 더 있습니다. 내가 어떻게 문제를 풀어야하는지.

감사의 말 전진.

+0

지금까지 작성한 코드를 표시 할 수 있습니까? –

+0

언젠가 전 가로 모드 (ipad에서)의 tabbar가 바닥에서 전체 길이로 오지 않기 때문에 나는이 필요성을 가지고 있습니다. 그렇지 않으면 ipad 응용 프로그램을 만들고 있지 않다면 UITabBarController가 답입니다. –

+0

귀하의 질문을 이해할 수 없습니다. 컨트롤러 열기가 무슨 뜻인지, U 액션을 동시에로드하고 싶습니다. 그런 다음 해당 버튼에 대해 다른 선택기가있는 4 개의 대상을 추가하십시오. 그래서 단일 버튼을 사용하여 다른보기 컨트롤러를 제어 할 수 있습니다. –

답변

2

당신이 설명하는 기능을 구현하는 UITabBarController을 사용 해본 적이 있습니까?

스크롤보기의 단추는 탭 표시 줄 기능 만 복제하므로 사용자 경험이 혼란 스럽습니다.

+0

기본적으로 모든 컨트롤러 (A, B, C, D)는 탭바 컨트롤러이며 버튼은이 컨트롤러의 탐색 막대에서 스크롤보기에 있습니다. – Emon

+1

버튼을 제거하지 않는 이유는 무엇입니까?탭바 기능 만 복제하면 사용자 경험이 혼란 스럽습니다. –

+0

당신은 나에게 멋진 해결책을 주었지만 어떻게 할 수 있을지 모르겠다. 한번 단계별로 설명해주십시오. 아직도 당신이 내 문제를 이해하기 위해 문제에 직면하고 있다면 다른 질문에 내 질문을 게시했습니다. 링크가 있습니다 ... http : //stackoverflow.com/questions/8801429/is-there-anyway-to -add-same-scroll-menubar-at-the-navigation-bar – Emon

0

스토리 보드 (새로운 ios 5 기능)를 사용하면 코드 작성의 어려움을 해결하는 데 도움이 될 것이라고 생각하지만 복잡한 기능을 혼란스럽게합니다.

콘센트를보기 컨트롤러에서 다른 세 개의보기로 연결하고 다른 세 개의보기에서이보기로 다시 연결해야합니다. 여기에서 자세한 내용을 확인할 수 있습니다. Link

+0

내 제안을 수정하지 않고 더 이상 제안을 드릴 수 있습니까? – Emon

+0

Pls. 코드를 게시하십시오. – mashios

+0

나는 나의 코드를 다시 편집했다. 이제 plz에게 해결책을 주겠다. 참고 사항 : pls 내 코드에 대한 내 의견을 참조하십시오. – Emon

관련 문제