2017-01-28 7 views
0

это мой UITabBarController код в appdelegate.m файлеКак нажать otherviewcontroller на событие uibutton click в uitabbarcontroller?

UITabBarController *tbController =(UITabBarController *)self.window.rootViewController; 
UITabBar *tbAppearence = [UITabBar appearance]; 

теперь у меня есть три button в одном из UITabBarController зрения, когда я нажимаю один из button экрана будет перенаправлять на другую точку зрения, но она не может ,

Это моя кнопка действия кода В UserInfoViewController.m файл

- (IBAction)AskQuestionButtonPressed:(id)sender 
{ 
    NSLog(@"Ask Button pressed"); 
    AskQuestion *AskQuestionObject = [self.storyboard instantiateViewControllerWithIdentifier:@"AskQuestionID"]; 
    [self.navigationController pushViewController:AskQuestionObject animated:YES];  
} 

плз помогите мне я новичок в ИОС.

+0

Проверить 'UIVC' идентификатор. –

+0

его же «AskQuestionID», но ничего не происходит. –

+0

Затем добавьте свой код штрих-кода. Я имею в виду, когда вы добавляете Vc в панель вкладок. –

ответ

0

Вы должны добавить свой UIViewcontroller в свой tabBar, как показано ниже.

Вот пример моего UITabBarController подкласса:

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    UIViewController *view1 = [[UIViewController alloc] init]; 
    UIViewController *view2 = [[UIViewController alloc] init]; 
    UIViewController *view3 = [[UIViewController alloc] init]; 

    NSMutableArray *tabViewControllers = [[NSMutableArray alloc] init]; 
    [tabViewControllers addObject:view1]; 
    [tabViewControllers addObject:view2]; 
    [tabViewControllers addObject:view3]; 

    [self setViewControllers:tabViewControllers]; 
    //can't set this until after its added to the tab bar 
    view1.tabBarItem = 
     [[UITabBarItem alloc] initWithTitle:@"view1" 
            image:[UIImage imageNamed:@"view1"] 
             tag:1]; 
    view2.tabBarItem = 
     [[UITabBarItem alloc] initWithTitle:@"view2" 
            image:[UIImage imageNamed:@"view3"] 
             tag:2]; 
    view3.tabBarItem = 
     [[UITabBarItem alloc] initWithTitle:@"view3" 
            image:[UIImage imageNamed:@"view3"] 
             tag:3];  
} 
+0

UIViewController * view1 = [[AskQuestion alloc] init]; NSMutableArray * tabViewControllers = [[NSMutableArray alloc] init]; [tabViewControllers addObject: view1]; [self setViewControllers: tabViewControllers]; view1.tabBarItem = [[UITabBarItem alloc] initWithTitle: @ "view1" image: [UIImage imageNamed: @ "view1"] tag: 1]; эта ошибка в [self setViewControllers: tabViewControllers]; Нет видимого @interface для 'UserInfoViewController' объявляет селектор setViewControllers: ' –

 Смежные вопросы

  • Нет связанных вопросов^_^