据我所知,我有很多问题只出现在 iOS 7.1.2 中;虽然我不确定它是否出现在早期版本中。在 iOS 7 上,我相信它很好,并且在模拟器上。
编辑**进一步的规范**
在 iOS 7.1.2 上,它适用于 iPhone 5,但不适用于 iPhone 5S
当我在设备上运行时,而不是在模拟器中。第一个单元格出现,但后续单元格不出现。登录 dequeue 方法显示单元已实例化并已出列。此外,除了在单元格中滚动之外,第一个单元格对 UI 完全没有响应。当我将单元格向上拖动到顶部时,它会出现直到到达表格 View 的顶部,然后完全消失。当我向下拖动单元格时,一切正常。
- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath
{
UITableViewCell *cell;
if(indexPath.row==0)
{
[self.restaurant sortRewards];
HeaderCell *headerCell = (HeaderCell *)[tableView dequeueReusableCellWithIdentifier"HeaderCell" forIndexPath:indexPath];
//set up the labels to be loaded from restaurant
headerCell.restaurantName.text=self.restaurant.name;
headerCell.restaurantType.text=self.restaurant.placeType;
headerCell.restaurantDetails.text=[self.restaurant getFormattedDetails];
headerCell.priceRating.text = [self.restaurant getPriceRatingString];
headerCell.address.text=self.restaurant.address;
headerCell.cityStateZip.text=[self.restaurant getCityStateZipString];
headerCell.phoneNumber.text=[self.restaurant phoneNumber];
headerCell.description.text=self.restaurant.restaurantDescription;
//set up the top most image from the header property of the restaurant
if([self.restaurant isHeaderLoaded]==YES)
{
headerCell.restaurantHeader.image=self.restaurant.header;
NSLog(@"Apparently the image loaded");
}else
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ // 1
NSData *data = [NSData dataWithContentsOfURL:[self.restaurant headerURL]];
UIImage *img = [[UIImage alloc] initWithData:data];
dispatch_async(dispatch_get_main_queue(), ^(void) {
self.restaurant.header=img;
self.restaurant.isHeaderLoaded=YES;
headerCell.restaurantHeader.image=img;
});
});
}
//load the correct badge for wireless or not
//as well as the correct use woblet now button
UIImage* image;
if(self.restaurant.isSitDown)
{
image = [UIImage imageNamed"ico_wireless-1"];
[headerCell.useWobletNow setBackgroundImage:[UIImage imageNamed"Use Woblet Button Wireless"] forState:UIControlStateNormal];
}
else
{
[headerCell.useWobletNow setBackgroundImage:[UIImage imageNamed"Use Woblet Button QR"] forState:UIControlStateNormal];
image = [UIImage imageNamed"ico_qr_code-1"];
}
headerCell.isSitdownBadge.image=image;
//set up the map
[headerCell.map setCenterCoordinate:[self.restaurant.location coordinate] animated:YES];
//set a pin on the map
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
[annotation setCoordinate:[self.restaurant.location coordinate]];
[headerCell.map addAnnotation:annotation];
//zoom that motherfucker in
[self zoomMapViewToFitAnnotations:headerCell.map animated:NO];
//set up the points circle
UIImageView *view = [[UIImageView alloc] init];
view.frame=CGRectMake(0, 0, headerCell.pointsImage.frame.size.height, headerCell.pointsImage.frame.size.height);
int percent = [self.restaurant.numberOfPoints intValue]%[[(Reward *)[self.restaurant.rewards objectAtIndex:[self.restaurant.rewards count]-1] pointsRequired] intValue];
percent = 100*percent/[[(Reward *)[self.restaurant.rewards objectAtIndex:[self.restaurant.rewards count]-1] pointsRequired] intValue];
[view applyCircleWithPercentage:percent andText:[NSString stringWithFormat"%@",[self.restaurant.numberOfPoints stringValue]] andTintColor:[UIColor colorWithRed:5.0f/255.0f green:98.0f/255.0f blue:238.0f/255.0f alpha:1.0f]];
//set the blue swirl
[headerCell.pointsImage addSubview:view];
//set the number of points until the next reward
headerCell.pointsUntilNextReward.text = [NSString stringWithFormat"%d pts",[self.restaurant pointsUntilNextReward]];
//assign our return cell to header cell
return headerCell;
}
else
{
//instantiate a RewardCell to reassign to cell at a later point
RewardCell *rewardCell;
//pull the appropriate reward from the restaurant
Reward *reward = [[self.restaurant rewards] objectAtIndex:indexPath.row-1];
if([reward.pointsRequired intValue]<=[self.restaurant.numberOfPoints intValue])
{
//if you have more points that the points required for a given reward dequeue with the identifier reward cell on in order to use the appropriate UI.
rewardCell = (RewardCell *)[tableView dequeueReusableCellWithIdentifier"RewardCellOn" forIndexPath:indexPath];
}
else
{
//otherwise you need to use the UI for when you don't have enough points.
rewardCell = (RewardCell *)[tableView dequeueReusableCellWithIdentifier"RewardCellOff" forIndexPath:indexPath];
}
//number of points you need to use a given reward need to be set
rewardCell.numberOfPointsRequired.text = [NSString stringWithFormat"%@ pts",reward.pointsRequired];
//the description needs to be set on the cell
rewardCell.rewardDescription.text=reward.rewardDescription;
//the cell needs to be assigned to our rewardCell that we instantiated and dequeued at the beginning on the if
return rewardCell;
}
return cell;
}
编辑:
对不起,在我的挫折中,我误读了一些东西。它适用于其中一部带有 7.1.2 的手机,而另一部带有 7.1.2 的手机则不适用。我要看看差异。
编辑 2:
我发现了问题,它在一段我没有包含的代码中:
-(float)tableViewUITableView *)tableView heightForRowAtIndexPathNSIndexPath *)indexPath
{
if(indexPath.row==0)
return 436;
return 55;
}
Best Answer-推荐答案 strong>
这里的问题在于我声明的方法具有与 64 位架构冲突的不正确返回类型:
-(float)tableViewUITableView *)tableView heightForRowAtIndexPathNSIndexPath *)indexPath
这会返回一个 float 。一切看起来都很老套,但在 64 位架构中这会失败,因为返回类型实际上是 CGFloat,它是一个可以返回 double 或浮点的宏。因此,在非 64 位架构中,从浮点到 CGFloat 的转换很好,因为在 32 位架构中 CGFloat 是浮点。在 64 位架构中,CGFloat 是一个 double;然而。
更改此位修复了之前出现的神秘错误。
-(CGFloat)tableViewUITableView *)tableView heightForRowAtIndexPathNSIndexPath *)indexPath
关于ios - UITableViewCells 未出现在 iPhone 5S 上的 iOS 7.1.2 中,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/25792393/
|