试图修复此错误:无法找到映射图像UIPickerViewFrameLeft-162-Popover.png [英] trying to fix this error: Could not find mapped image UIPickerViewFrameLeft-162-Popover.png

查看:95
本文介绍了试图修复此错误:无法找到映射图像UIPickerViewFrameLeft-162-Popover.png的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以编程方式创建uiPickerView并将其添加到视图中而不使用界面构建器。不要误会我的意思,我喜欢IB,但我想这样做的原因是因为我正在尝试构建一个对象,我可以使用UIPopoverViewController和各种不同的子视图快速插入以生成弹出菜单(例如uiPickerView)作为弹出窗口中的菜单。我已经通过在IB中构建菜单并使用其ViewController初始化弹出窗口来完成这项工作,因此我知道这在大多数情况下是如何工作的。

I'm trying to create programmatically a uiPickerView and add it to a view without using interface builder. Don't get me wrong, I like IB but the reason why I want to do it this way is because i'm trying to build an object that I can quickly plug in to produce popup menus using UIPopoverViewController and a variety of different subViews (such as uiPickerView) as the menu in the popup. I've already made this work by building the menu in IB and initializing the popup with its ViewController so I know how this works for the most part.

我已输入下面的相关代码,这是我运行时得到的两个错误:
- 无法找到映射图像UIPickerViewFrameRight-162-Popover.png
- 无法找到映射图像UIPickerViewFrameLeft-162 -Popover.png

I've entered the relevant code below and this is the two errors I get when I run it: - "Could not find mapped image UIPickerViewFrameRight-162-Popover.png" - "Could not find mapped image UIPickerViewFrameLeft-162-Popover.png"

我不知道这些图片是什么,但我认为它们是选择器视图的png。

I don't know what these images are but I'm assuming they are the png's of the picker view.

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];

现在这个代码会崩溃程序,除非你删除我试图添加选择器的行查看,此时我只得到空白的弹出窗口。所以我知道这是导致这个问题的选择器,但我不知道如何解决它。我一整天都在搜索,但是每个关于uipickers的在线教程都包括使用IB。我的猜测是,这是一个非常愚蠢的错误,比如错过导入或者其他什么,但是如果有人能告诉我我做错了什么就会非常感激。

Now this Code will crash the program unless you remove the line where I try to add the picker to the view, at which point I just get the blank popover. So I know that it is the picker that is causing this issue however I don't know how to fix it. I've been searching all day but every tutorial online on uipickers all include using IB. My guess is that this is a really stupid error like missing an import or something but if anyone can tell me what I'm doing wrong it would be greatly appreciated.

请注意,我按照教程了解如何为UIPickerView设置dataSource和委托方法,我很确定它们没问题但是如果你想在这里验证你是:再次感谢。

Also note that I followed the tutorials on how to set up the dataSource and delegate methods for the UIPickerView and I'm pretty sure they are fine however if you want to verify here you are: 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.
    // e.g. 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 {
}


推荐答案

好吧我不太确定发生了什么但是我删除了这个项目并重新编写了这段代码并且没有更多问题。

Alright well I'm not quite sure what happened but I deleted the project and re-wrote this code and voila... No more issues.

这篇关于试图修复此错误:无法找到映射图像UIPickerViewFrameLeft-162-Popover.png的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆