使用iOS系统中的编辑联系人界面,其中的思路值得借鉴(继承的思想)

使用iOS系统中的编辑联系人界面

On 2012/12/04, in Objective-C, iOS控件, by willonboy

 

http://willonboy.tk/

//ContactInfoCell.h

ABPersonViewController  *personViewVC;

@property(nonatomic, assign) UINavigationController *globalNav;

 

 

- (void)handleEditBtnClicked:(id)sender

{

    if (!personViewVC)

    {

        personViewVC = [ABPersonViewController new];

    }

    personViewVC.personViewDelegate = self;

    personViewVC.allowsEditing = YES;

    personViewVC.editing = YES;

    

    ABAddressBookRef abRef = [ABAddressBookDataControllermakeABAddressBookRef];

    personViewVC.displayedPerson = ABAddressBookGetPersonWithRecordID(abRef, self.entity.recordId);

    

    UINavigationController *subNav = [[UINavigationController allocinitWithRootViewController:personViewVC];

    subNav.navigationBarHidden = NO;

    

    UINavigationBar *subNavBar = [[UINavigationBar allocinitWithFrame:CGRectMake(02032044)];

    subNavBar.barStyle = UIBarStyleDefault;

    

    UINavigationItem *navItem = [[UINavigationItem allocinitWithTitle:@"编辑联系人"];

    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"取消style:UIBarButtonSystemItemCancel target:self action:@selector(cancelEdit:)];

    UIBarButtonItem *okItem = [[UIBarButtonItem alloc] initWithTitle:@"完成style:UIBarButtonSystemItemCancel target:self action:@selector(okEdit:)];

    navItem.leftBarButtonItem = backItem;

    navItem.rightBarButtonItem = okItem;

    

    subNavBar.items = [NSArray arrayWithObjects:navItem, nil];

    [subNav.view addSubview:subNavBar];

    

    [self.globalNav.topViewController presentModalViewController:subNav animated:YES];

    

    [subNavBar release];

    [navItem release];

    [backItem release];

    [okItem release];

    [subNav release];

    CFRelease(abRef);

}

 

 

- (void)cancelEdit:(id)sender

{

    [self.globalNav.topViewController dismissModalViewControllerAnimated:YES];

}

 

 

- (void)okEdit:(id)sender

{

    [[personViewVC editButtonItem].target performSelector:[personViewVC editButtonItem].action];

    NSLog(@"okedit");

    [self cancelEdit:nil];

}

 

- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier;

{

    return NO;

}

 

 

 

http://github.com/willonboy


你可能感兴趣的:(使用iOS系统中的编辑联系人界面,其中的思路值得借鉴(继承的思想))