비슷한 질문을 찾고 있었지만 문제가 무엇인지 알아낼 수 없었습니다. 작동해야하지만 오류가 있습니다.IOS 5.1 ARC 인식 할 수없는 선택기 인스턴스로 보냈습니다
IOS 5.1 Ipad Stortyboard 응용 프로그램에서 사용자가 팝업보기를 클릭하면 열어야하는 오른쪽 탐색 모음 항목이 있습니다. 그래서 나는 그것이 나에게주는 이제 새로운 팝 오버 클래스 다음 나는 기능을 다음과 같은 시도했지만 아무도 지금까지 일을하지 않았다
-[UIButton view]: unrecognized selector sent to instance 0xa17ba80
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton view]: unrecognized selector sent to instance 0xa17ba80'
오류로 대체 내가 일하는 팝 오버보기를했지만, 디자인은 좋지 않았다. 코드를 변경하면 비슷한 오류가 발생합니다.
- (IBAction)setColorButtonTapped:(id)sender{
- (void)setColorButtonTapped:(id)sender{
- (IBAction)setColorButtonTapped:(id)sender forEvent:(UIEvent*)event {
- (void)setColorButtonTapped:(id)sender forEvent:(UIEvent*)event {
그리고 당연히 나는 IBAction를 또는 무효
[backButton2 addTarget:self action:@selector(setColorButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
여기
코드 my.h 파일을입니다
#import <UIKit/UIKit.h>
#import "ColorPickerController.h"
@interface MeetingViewController : UITableViewController<UIApplicationDelegate,UIAlertViewDelegate,DropDownListDelegate,MFMailComposeViewControllerDelegate,EGORefreshTableHeaderDelegate,ColorPickerDelegate>{
UIPopoverController *_popover;
ColorPickerController *_colorPicker;
UIPopoverController *_colorPickerPopover;
}
@property (nonatomic, strong) UIPopoverController *popover;
@property (nonatomic, strong) ColorPickerController *colorPicker;
@property (nonatomic, strong) UIPopoverController *colorPickerPopover;
- (IBAction)setColorButtonTapped:(id)sender;
@end
my.m 파일에 대한 다음과 같은 TI을 변경 한
,210@synthesize popover = _popover;
@synthesize colorPicker = _colorPicker;
@synthesize colorPickerPopover = _colorPickerPopover;
- (void)viewDidLoad
{
[super viewDidLoad];
//gear button on navigation Bar
UIImage* imageback2 = [UIImage imageNamed:@"ICON - [email protected]"];
CGRect frameimgback2 = CGRectMake(0, 0, 40, 40);
UIButton *backButton2 = [[UIButton alloc] initWithFrame:frameimgback2];
[backButton2 setBackgroundImage:imageback2 forState:UIControlStateNormal];
[backButton2 addTarget:self
action:@selector(setColorButtonTapped:)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *btn2 = [[UIBarButtonItem alloc] initWithCustomView:backButton2];
self.navigationItem.rightBarButtonItem = btn2;
}
#pragma mark ColorPickerDelegate
- (void)colorSelected:(NSString *)color {
[self.colorPickerPopover dismissPopoverAnimated:YES];
}
#pragma mark Callbacks
- (IBAction)setColorButtonTapped:(id)sender {
if (_colorPicker == nil) {
self.colorPicker = [[ColorPickerController alloc] initWithStyle:UITableViewStylePlain];
_colorPicker.delegate = self;
self.colorPickerPopover = [[UIPopoverController alloc] initWithContentViewController:_colorPicker];
}
[self.colorPickerPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
유틸리티 클래스 ColorPickerController.h
#import <UIKit/UIKit.h>
@protocol ColorPickerDelegate
- (void)colorSelected:(NSString *)color;
@end
@interface ColorPickerController : UITableViewController {
NSMutableArray *_colors;
id<ColorPickerDelegate> __weak _delegate;
}
@property (nonatomic, strong) NSMutableArray *colors;
@property (nonatomic, weak) id<ColorPickerDelegate> delegate;
@end
utilityclass ColorPickerController.m
#import "ColorPickerController.h"
@implementation ColorPickerController
@synthesize colors = _colors;
@synthesize delegate = _delegate;
#pragma mark -
#pragma mark Initialization
/*
- (id)initWithStyle:(UITableViewStyle)style {
// Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
if ((self = [super initWithStyle:style])) {
}
return self;
}
*/
#pragma mark -
#pragma mark View lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(150.0, 140.0);
self.colors = [NSMutableArray array];
[_colors addObject:@"Red"];
[_colors addObject:@"Green"];
[_colors addObject:@"Blue"];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Override to allow orientations other than the default portrait orientation.
return YES;
}
#pragma mark -
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [_colors count];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
NSString *color = [_colors objectAtIndex:indexPath.row];
cell.textLabel.text = color;
return cell;
}
#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (_delegate != nil) {
NSString *color = [_colors objectAtIndex:indexPath.row];
[_delegate colorSelected:color];
}
}
#pragma mark -
#pragma mark Memory management
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Relinquish ownership any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
// For example: self.myOutlet = nil;
}
- (void)dealloc {
self.delegate = nil;
}
@end
도움이 많이 감사
스토리 보드를 사용하는 경우 왜 지그재그 혜택을받지 마십시오. 버튼에서 세그를 드래그하여 popover 내에 표시 할보기로 드래그하고 "popover"를 선택할 수 있습니다. 나는 이것을 사용할 때마다 "Ctrl"키를 누른 상태에서 단추에서보기로 끌어서 놓기 만하면됩니다. – Diwann
팝업은 사용자가 목록을 클릭하면 현재보기를 변경하지 않고 드롭 다운 또는 팝 오버했을 때의 드롭 다운 목록과 비슷합니다. 어떻게 그걸 segue로 달성 했습니까? –
다른 것과 마찬가지로 : 키보드의 "ctrl"키를 길게 누르기 만하면 단추에서 _colorPicker보기로 끌 수 있습니다. – Diwann