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

 

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;

}

 

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

 

 

http://github.com/willonboy


上一篇:【Java学习笔记】HashSet中加入自定义的类的对象


下一篇:maven学习笔记