为什么模拟器iPhone/iPad给出的结果与iPhone视网膜(4英寸)和iPhone视网膜(4英寸64位)不同
这是我第一次问问题,因为我是新来的。非常感谢您的回答!谢谢你抽出时间 使用Xcode 5.1.1 这是我的问题,当在模拟器或实际设备上测试时,结果是不同的。 见附在食品图片上的截图。当我在模拟器iPhone视网膜(4英寸64位)上测试时,结果是正确的,食物图像显示正确并且与文本匹配 当我在模拟器iPhone视网膜(4英寸)上测试时,结果不正确,食物图像显示与文本不匹配 我还测试了实际设备,比如iPad Air显示器是否正确,但iPad3不正确。食品图像显示与文本不匹配 你能帮我解决这个问题吗?我不明白为什么相同的代码会产生不同的结果为什么模拟器iPhone/iPad给出的结果与iPhone视网膜(4英寸)和iPhone视网膜(4英寸64位)不同,iphone,ipad,Iphone,Ipad,这是我第一次问问题,因为我是新来的。非常感谢您的回答!谢谢你抽出时间 使用Xcode 5.1.1 这是我的问题,当在模拟器或实际设备上测试时,结果是不同的。 见附在食品图片上的截图。当我在模拟器iPhone视网膜(4英寸64位)上测试时,结果是正确的,食物图像显示正确并且与文本匹配 当我在模拟器iPhone视网膜(4英寸)上测试时,结果不正确,食物图像显示与文本不匹配 我还测试了实际设备,比如iPad Air显示器是否正确,但iPad3不正确。食品图像显示与文本不匹配 你能帮我解决这个问题吗?我
for (NSUInteger i=0; i<30; i++)
{
UIImage *anImage = [UIImage imageNamed:[NSString stringWithFormat:@"food%d.jpg", (int)i+1]];
[arrimagefood addObject:anImage];
}
[ArrforAllDicFood addObjectsFromArray:[DictionaryForEnglishFood allKeys]];
[TableForFood reloadData];
for(i=0;i字典没有顺序,因此'allKeys'方法可以返回任何顺序。甚至不能保证从一个调用到另一个调用的顺序相同。添加、删除或更改条目也可能导致返回不同的顺序
你需要做的是将图像名称(或名称索引)和食物名称包含在一个结构中。依赖顺序不是一个好的解决方案
模拟器就是这样,它运行的代码是为英特尔处理器模拟设备而编译的。设备代码是为ARM处理器编译的。人们可以预料到不同之处,比如你看到的任何键顺序都是正确的
仿真器通过模拟相同的指令来运行其他处理器的代码,结果将是每个设备上的顺序相同,但又是任意顺序。谢谢Zaph。食物图像已经被命名为food1、food1、food3…它显示正确的顺序,但文本没有顺序,与食物图像不匹配。我提供了详细信息因此,请看一看,你能告诉我如何解决这个问题吗?问题是,当测试模拟机iPhone(4英寸)或实际设备(如iPhone 5)时,结果(文本)与食物图像不一致,但与模拟机iPhone(4英寸64位)运行与食物图像匹配/订购。那么我如何更改代码以使其同时适用于iPhone(4英寸)和iPhone(4英寸64位)。非常感谢您的帮助!食品图像显示1-30之间的订单,但只有文本发生了变化,我不知道该怎么办。再次感谢。@Souli我已经移动并格式化了您问题注释中的代码。您可以删除代码注释。@非常感谢Zaph的格式化代码,现在很容易阅读。我尝试复制所有和过去的代码e但不允许使用该系统。
- (void)viewDidLoad {
[super viewDidLoad]; DictionaryForEnglishFood=[[NSMutableDictionary alloc]init];
DictionaryForLaoFood=[[NSMutableDictionary alloc]init];
DictionaryForPythnFood=[[NSMutableDictionary alloc]init];
DictionaryForImageFood=[[NSMutableDictionary alloc]init];
DictionaryForAudioFood=[[NSMutableDictionary alloc]init];
ArrforAllDicFood=[[NSMutableArray alloc]init];
arrimagefood=[[NSMutableArray alloc]init];
// add English German food
// [DictionaryForEnglishFood setValue:@"Asparagus" forKey:@"food1"];//5
// [DictionaryForEnglishFood setValue:@"Lobscouse" forKey:@"food2"];//29
// [DictionaryForEnglishFood setValue:@"Sauerkraut" forKey:@"food3"];//22
// [DictionaryForEnglishFood setValue:@"Potatoes" forKey:@"food4"]; //16
// [DictionaryForEnglishFood setValue:@"Pumpkin bread" forKey:@"food5"];//11
// [DictionaryForEnglishFood setValue:@"Asparagus Sauce" forKey:@"food6"];//6
// ......
// Add German words
// [DictionaryForLaoFood setValue:@"Spargel" forKey:@"food1"];//5
// [DictionaryForLaoFood setValue:@"Labskaus" forKey:@"food2"];//29
// [DictionaryForLaoFood setValue:@"Sauerkraut" forKey:@"food3"];//22
// [DictionaryForLaoFood setValue:@"Pellkartoffeln" forKey:@"food4"]; //16
// [DictionaryForLaoFood setValue:@"Kürbisbrot" forKey:@"food5"];//11
// [DictionaryForLaoFood setValue:@"Spargelsoße" forKey:@"food6"];//6
// ........
// Add German pronounciation
// [DictionaryForPythnFood setValue:@"Shpahrg-uhl" forKey:@"food1"];//5
// [DictionaryForPythnFood setValue:@"Lahbs-cows" forKey:@"food2"];//29
// [DictionaryForPythnFood setValue:@"Sour-krout" forKey:@"food3"];//22
// [DictionaryForPythnFood setValue:@"Pehl-car-tohf-ehln" forKey:@"food4"]; //16
// [DictionaryForPythnFood setValue:@"Koorb-is-broht" forKey:@"food5"];//11
// [DictionaryForPythnFood setValue:@"Shpahrg-uhl-sohs-uh" forKey:@"food6"];//6
// ......
// Add German audio
// [DictionaryForAudioFood setValue:@"aspargus" forKey:@"food1"];//5
// [DictionaryForAudioFood setValue:@"lobscouse" forKey:@"food2"];//29
// [DictionaryForAudioFood setValue:@"sauerkraut" forKey:@"food3"];//22
// [DictionaryForAudioFood setValue:@"potatoes" forKey:@"food4"]; //16
// [DictionaryForAudioFood setValue:@"pumpkin bread" forKey:@"food5"];//11
// [DictionaryForAudioFood setValue:@"aspargus sauce" forKey:@"food6"];//6
// ....
for (NSUInteger i=0; i<30; i++) {
UIImage *anImage = [UIImage imageNamed:[NSString stringWithFormat:@"food%d.jpg", (int)i+1]];
[arrimagefood addObject:anImage];
}
[ArrforAllDicFood addObjectsFromArray:[DictionaryForEnglishFood allKeys]];
[TableForFood reloadData];
}
-(UITableViewCell )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if([[ UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPhone) {
static NSString *CellIdentifier = @"CustomCellPlace";
CustomCellPlace *cell= (CustomCellPlace) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// create a uitableviewcell
// if(cell == nil) {
// NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCellPlace" owner:self options:nil];
// for (id currentObject in topLevelObjects) {
// if ([currentObject isKindOfClass:[UITableViewCell class]]) {
// cell = currentObject;
// }
// }
// }
cell.tag=indexPath.row;
cell.backgroundColor = [UIColor clearColor];
cell.backgroundView = [UIView new] ;
cell.selectedBackgroundView = [UIView new] ;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.lb1.text=[DictionaryForEnglishFood objectForKey:[ArrforAllDicFood objectAtIndex:indexPath.row]];
cell.lb2.text=[DictionaryForLaoFood objectForKey:[ArrforAllDicFood objectAtIndex:indexPath.row]];
cell.lb3.text=[DictionaryForPythnFood objectForKey:[ArrforAllDicFood objectAtIndex:indexPath.row]];
for(int i=0; i<[arrimagefood count];i++) {
NSUInteger str=indexPath.row;
cell.imageview.image=[arrimagefood objectAtIndex:str];
} return cell;
}
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [ArrforAllDicFood count];
}