繁体   English   中英

在UITabBarController中的ViewController中呈现视图

[英]Presenting a view in a ViewController that is in a UITabBarController

我仍在学习iOS开发,因此,如果我的标题不正确,我深表歉意:(

我有一个TabBarController,与之关联的视图之一具有自己的ViewController类。 我正在尝试在加载此场景时显示iOS联系人。 我希望联系人界面包含在标签栏范围内。 现在,它弹出并替换了整个场景,因此我失去了底部的标签栏。 我想保留它。

有什么建议么?

这是我当前上课的代码

#import "DeviceContactsViewController.h"

@interface DeviceContactsViewController ()

@end

@implementation DeviceContactsViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization

    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidAppear:(BOOL)animated
{
    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    picker.peoplePickerDelegate = self;

   [self presentViewController:picker animated:YES completion:nil];
}

#pragma mark - Contacts

- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker
      shouldContinueAfterSelectingPerson:(ABRecordRef)person {
    [self dismissViewControllerAnimated:YES completion:nil];

    return NO;
}


- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
      shouldContinueAfterSelectingPerson:(ABRecordRef)person
                                property:(ABPropertyID)property
                              identifier:(ABMultiValueIdentifier)identifier
{
    return NO;
}

@end

场景

发生这种情况是因为您说的是[self presentViewController:picker animated:YES completion:nil]; ,无论您是否具有标签栏或导航栏,该行都将在所有内容之上显示您的视图。

Tabbar的默认行为是将每个选项卡链接到单独的ViewController,因此每个Tabbaritem应该从StoryBoard链接到ViewController,与呈现ViewController无关,默认情况下会发生,所有转换视图控制器之间默认发生。

查看本教程,您将看到它们如何链接在一起: Ray Wenderlich,StoryBoards链接

希望能帮助到你 :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM