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 に答える