0

我在我的应用程序中实现了 ABPersonView 以允许查看联系人。选择电子邮件字段后,电子邮件应用程序将按预期打开,但灰色状态栏仅出现在 iPad 上,而在 iPhone 上则没有。我没有使用 IB,代码非常简单和标准来实现 ABPersonView。如果有人需要特定代码,请指定哪个代码部分。我很难过,因为这个问题只出现在 iPad 上。如何在 iPad 上停止这种行为?

编辑:我用一个虚拟项目重新创建了这种不受欢迎的行为。

#import <UIKit/UIKit.h>
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>

@interface RootViewController: UIViewController <ABPersonViewControllerDelegate> {


}


@end

在.m

#import "RootViewController.h"


@implementation RootViewController


- (void)loadView {

    self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    self.view.backgroundColor = [UIColor whiteColor];
    self.view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;


UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(21, 80, 100, 35);
[myButton setTitle:@"My Button" forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(myButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:myButton];

}

-(void)myButtonPressed{

    ABPersonViewController *personViewController = [[[ABPersonViewController alloc] init] autorelease];
personViewController.displayedPerson = [self personObject];
[self.navigationController pushViewController:personViewController animated:YES];


}

- (ABRecordRef)personObject {

ABRecordRef newRecord = ABPersonCreate();

ABRecordSetValue(newRecord, kABPersonFirstNameProperty, CFSTR("John"), nil);    
ABRecordSetValue(newRecord, kABPersonLastNameProperty, CFSTR("Doe"), nil); 

ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(multiPhone, @"1-222-333-4444", kABPersonPhoneMainLabel, NULL);
ABRecordSetValue(newRecord, kABPersonPhoneProperty, multiPhone, nil);
CFRelease(multiPhone);

ABMutableMultiValueRef multiEmail = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(multiEmail, @"123@abc.com", kABWorkLabel, NULL);
ABRecordSetValue(newRecord, kABPersonEmailProperty, multiEmail, nil);
CFRelease(multiEmail);

ABMutableMultiValueRef address = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
NSMutableDictionary *addressDict = [[NSMutableDictionary alloc] init];
[addressDict setObject:@"1234 AnyStreet" forKey:(NSString *)kABPersonAddressStreetKey];
[addressDict setObject:@"AnyTown" forKey:(NSString *)kABPersonAddressCityKey];
[addressDict setObject:@"AnyState" forKey:(NSString *)kABPersonAddressStateKey];
[addressDict setObject:@"55555" forKey:(NSString *)kABPersonAddressZIPKey];
ABMultiValueAddValueAndLabel(address, addressDict, kABWorkLabel, nil);
ABRecordSetValue(newRecord, kABPersonAddressProperty, address, nil);

return newRecord;
}

- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue
{
    return YES;
}

@end
4

1 回答 1

0

你想要的行为到底是什么?

如果您希望完全删除状态栏,可以使用以下命令将其隐藏:

[[UIApplication sharedApplication] setStatusBarHidden:YES];

您还可以设置其样式和框架。所有这些都Apple Developer 文档中。请参阅控制应用外观

于 2014-04-08T17:38:55.040 回答