Trying to fix this error: Could not find display image UIPickerViewFrameLeft-162-Popover.png

I am trying to create a uiPickerView programmatically and add it to the view without using the interface constructor. Don't get me wrong, I like IB, but the reason I want to do this is because I am trying to create an object that I can quickly connect to create pop-up menus using the UIPopoverViewController and various subtypes (like uiPickerView for example ) as a menu in a popup window. I already did this job by creating a menu in IB and initializing a popup using the ViewController, so I know how this works for the most part.

I entered the appropriate code below, and these are two errors that I get when I start: - "Could not find the displayed image UIPickerViewFrameRight-162-Popover.png" - "Could not find the displayed image UIPickerViewFrameRight-162-Popover.png"

I do not know what kind of images these are, but I assume that they are picker png representations.

menu = [[UIPickerView alloc]initWithFrame:CGRectMake(0,100,162,162)]; menu.delegate = self; menu.dataSource = self; [menu reloadAllComponents]; [menu selectRow:0 inComponent:0 animated:YES]; //Add the picker to the view [customViewController.view addSubview:menu]; popView = [[UIPopoverController alloc] initWithContentViewController:customViewController] ; [popView setDelegate:self]; CGRect pos = [rootView frame]; [popView presentPopoverFromRect:CGRectMake(pos.origin.x,pos.origin.y,0,pos.size.height) inView:displayView permittedArrowDirections:arrowDir animated:YES]; 

Now this code will crash the program if you do not delete the line where I am trying to add a collector to the view, after which I just get an empty spot. Therefore, I know that this is the collector that causes this problem, but I do not know how to fix it. I searched all day, but every online tutorial on uipickers includes using IB. I suppose this is a really stupid mistake, for example, the lack of imports or something like that, but if someone tells me what I'm doing wrong, we will be very grateful.

Also note that I have been following tutorials on setting up the dataSource and delegation methods for UIPickerView, and I'm sure they are fine, but if you want to check that you are here: Thanks again.

 #import "PopUpMenuViewController.h" @implementation PopUpMenuViewController @synthesize menuType; @synthesize data; @synthesize popView; @synthesize menu; @synthesize customViewController; #pragma mark - #pragma mark UIPOPOVERCONTROLLER DELEGATE METHODS #pragma mark - - (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController{ //Delegate this too the User of this class return TRUE; } - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController{ //Delegate this too the User of this class } #pragma mark - #pragma mark CUSTOM POPOVERVIEWCONTROLLER METHODS #pragma mark - -(void) initWithMenuType:(int)type{ menuType = type; } -(id) initWithMenuType:(int)type andData:(NSMutableArray *)dataSet fromViewItem:(id)sender withMainView:(UIView *)mView{ [super init]; menuType = type; data = dataSet; rootView = sender; displayView = mView; arrowDir = UIPopoverArrowDirectionUp; customViewController = [[UIViewController alloc] initWithNibName:@"PopUpMenu" bundle:nil]; return self; } -(void) setPopUpArrowDirection:(UIPopoverArrowDirection) arrow{ arrowDir = arrow; } -(void) showPopUp{ //UIPicker Menu if (menuType==1) { //UIPicker Setup menu = [[UIPickerView alloc]initWithFrame:CGRectMake(0,100,162,162)]; menu.delegate = self; menu.dataSource = self; [menu reloadAllComponents]; [menu selectRow:0 inComponent:0 animated:YES]; //Add the picker to the view [customViewController.view addSubview:menu]; popView = [[UIPopoverController alloc] initWithContentViewController:customViewController] ; [popView setDelegate:self]; CGRect pos = [rootView frame]; [popView presentPopoverFromRect:CGRectMake(pos.origin.x,pos.origin.y,0,pos.size.height) inView:displayView permittedArrowDirections:arrowDir animated:YES]; //[popView setPopoverContentSize:CGSizeMake(menu.frame.size.width+5,menu.frame.size.height+5)]; } } #pragma mark - #pragma mark VIEW CONTROLLER DELEGATE METHODS #pragma mark - // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. /* - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization. } return self; } */ /* // Implement loadView to create a view hierarchy programmatically, without using a nib. - (void)loadView { } */ /* // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; }*/ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Overriden to allow any orientation. return YES; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc. that aren't in use. } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // eg self.myOutlet = nil; } - (void)dealloc { [super dealloc]; [data release]; [popView release]; [menu release]; [rootView release]; [displayView release]; [customViewController release]; } #pragma mark - #pragma mark UIPICKERVIEW DELEGATE & DATASOURCE METHODS #pragma mark - #pragma mark - #pragma mark UIPickerViewDataSource Methods - (NSInteger) pickerView: (UIPickerView *) pickerView numberOfRowsInComponent: (NSInteger) component { return [data count]; } - (NSInteger) numberOfComponentsInPickerView: (UIPickerView *) pickerView { return 1; } #pragma mark - #pragma mark UIPickerViewDelegate Methods // Row height in pixels - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component { return 40.0f; } // Column width in pixels - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { return 90.0f; } - (NSString *) pickerView: (UIPickerView *) pickerView titleForRow: (NSInteger) row forComponent: (NSInteger) component { return [data objectAtIndex:row]; } - (void) pickerView: (UIPickerView *) pickerView didSelectRow: (NSInteger) row inComponent: (NSInteger) component { } 
+3
objective-c ipad
source share
3 answers

Well, I'm not quite sure what happened, but I deleted the project and rewrote this code and voila ... No problem.

+2
source share

If someone else encounters this particular warning in the console “Could not find the displayed image UIPickerViewFrameRight-162-Popover.png”, I think I understood why it appears.

HIG indicates that UIPickerView should only be added to Popover on the iPad.

"On the iPad, imagine the date and time of the selection only inside the popover."

http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/UIElementGuidelines/UIElementGuidelines.html

In my experiments, the UIPickerView should be the direct and only view of the current UIViewController in the popover. If the UIPickerView appears elsewhere in the view hierarchy, a warning appears and the UIPickerView will look bad (for example, it skips the left and right parts of the view).

In the above code, you can see that the UIPickerView has been added as a subset of the rootView in the customController:

 [customViewController.view addSubview:menu]; 

Perhaps this would work if the UIPickerView was the root view in the customController.

You can programmatically make UIPickerView the root view of the controller by overriding the loadView method of the controller and assigning the UIPickerView directly to the root view of the controller:

 - (void)loadView { CGRect frame = CGRectMake(0,0, 300, 300); UIPickerView *v = [[[UIPickerView alloc] initWithFrame:frame] autorelease]; v.delegate = self; // assuming controller adopts UIPickerViewDelegate v.dataSource = self; // assuming controller adopts UIPickerViewDataSource self.view = v; } 

Hope this helps someone.

+5
source share

I recently ran into the same issue with my app on iPad and iPhone. In fact, it was a simple, but stupid fix, due to the fact that the height of the iPad at 180 and 162 was iPhone. God must love an apple, but I do not.

0
source share

All Articles