【发布时间】:2019-07-19 11:30:17
【问题描述】:
当我点击 UIBarButtonItem 时,我的应用程序崩溃了。我尝试了许多不同的方法来编写将被调用的函数,但到目前为止找不到解决方案。我的代码如下。感谢您的帮助!
#import <Foundation/Foundation.h>
#include<pthread.h>
#import <Contacts/Contacts.h>
#import <ContactsUI/ContactsUI.h>
#import <ContactsUI/CNContactViewController.h>
#import <UIKit/UIKit.h>
@interface AddressBookAccess:UIViewController
@end
@implementation AddressBookAccess:UIViewController
+(BOOL)AddNewContact
{
// Removing code here
newNavigationController.navigationBar.topItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Back to AReach" style:UIBarButtonItemStylePlain target:self action:@selector(pressButton:)];
[viewController presentViewController:newNavigationController animated:YES completion:nil];
return YES;
}
-(IBAction)pressButton:(UIBarButtonItem*)btn
{
NSLog(@"button tapped %@", btn.title);
}
@end
【问题讨论】:
-
请添加有关崩溃的更多信息。
标签: ios objective-c button uibarbuttonitem