Apple AppStore中的我的应用程序有一个UIPopoverView,它只能部分呈现。它在屏幕上只显示一半,如屏幕快照中所示。 它只是应用程序的少数客户而不是我的任何测试设备。
我不知道为什么会这样。
这是soucrecode:
#import "TripsTableViewController.h"
#import "Database+Trip.h"
#import "Utils.h"
#import "TripAnnotationLayer.h"
#import "TripPointsTableViewController.h"
#import "TripsSortCell.h"
#define dumpTrips() NSLog(@"Trips: %@", [trips description])
@interface TripsTableViewController () {
NSArray *trips;
NSInteger sortSegment;
}
@end
@implementation TripsTableViewController
@synthesize mapView;
- (void)viewDidLoad
{
LogMethod();
dumpTrips();
[super viewDidLoad];
self.tableView.allowsSelectionDuringEditing = YES;
self.clearsSelectionOnViewWillAppear = NO;
sortSegment = 0;
}
- (void) viewWillAppear:(BOOL)animated {
LogMethod();
dumpTrips();
[self reloadTrips];
[super viewWillAppear:animated];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
LogMethod();
dumpTrips();
return 2;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
LogMethod();
dumpTrips();
return indexPath.section!=0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
LogMethod();
dumpTrips();
if (section==0) return 1;
return [trips count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
LogMethod();
dumpTrips();
if (indexPath.section == 0) {
TripsSortCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TripsSortCell"];
if (cell == nil) {
cell = [[TripsSortCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TripsSortCell"];
}
cell.tripsTableViewController = self;
[cell.sortSegment setSelectedSegmentIndex:sortSegment];
return cell;
} else {
static NSString *CellIdentifier = @"TripsCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
NSArray *row = trips[indexPath.row];
NSString *name = row[1];
cell.textLabel.text = name;
NSInteger tripID = [row[0] integerValue];
double tripLength = [[Database sharedInstance] getTripLength:tripID];
cell.detailTextLabel.text = [Utils getDistanceAsString:tripLength forKey:@"distance"];
cell.tag = tripID;
return cell;
}
}
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
LogMethod();
dumpTrips();
if ([[segue identifier] isEqualToString:@"TripPoints"]) {
UITableViewCell *cell = (UITableViewCell *) sender;
NSInteger tripID = cell.tag;
TripPointsTableViewController *target = (TripPointsTableViewController *) segue.destinationViewController;
target.tripID = tripID;
target.mapView = mapView;
}
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
LogMethod();
dumpTrips();
if (editingStyle == UITableViewCellEditingStyleDelete) {
[tableView beginUpdates];
NSInteger tripID = [trips[indexPath.row][0] integerValue];
[[Database sharedInstance] removeTrip:tripID];
trips = [[Database sharedInstance] getTrips];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView endUpdates];
if ([trips count] == 0) {
[[Database sharedInstance] createTripWithName:@"trip"];
[self reloadTrips];
}
NSInteger newTripID = [trips[0][0] integerValue];
[self setSelectedTripID:newTripID];
}
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
LogMethod();
dumpTrips();
if (indexPath.section==0) return;
NSInteger newTripID = [trips[indexPath.row][0] integerValue];
[self setSelectedTripID:newTripID];
self.mapView.tripsAnnotationLayer.visible = YES;
}
- (IBAction)addTrip:(UIBarButtonItem *)sender {
LogMethod();
dumpTrips();
[[Database sharedInstance] createTripWithName:@"trip"];
[self reloadTrips];
}
- (void) setSelectedTripID:(NSInteger) newTripID {
LogMethod();
dumpTrips();
self.mapView.tripsAnnotationLayer.tripID = newTripID;
NSArray *trippoints = [[Database sharedInstance] getTripPointsOfTrip:newTripID];
if ([trippoints count]>0) {
NSArray *row = trippoints[0];
CLLocationCoordinate2D coordinate;
coordinate.latitude = [row[2] doubleValue];
coordinate.longitude = [row[3] doubleValue];
double zoomLimit = 8.999;
if (mapView.visibleTileSource>1)
zoomLimit = 14.0;
if (mapView.zoom >= zoomLimit) {
[mapView setCenterCoordinate:coordinate animated:NO];
} else {
[mapView setZoom:zoomLimit atCoordinate:coordinate animated:NO];
}
}
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
LogMethod();
dumpTrips();
NSString *sectionName;
switch (section)
{
case 0:
sectionName = NSLocalizedString(@"Sort", @"Sort");
break;
case 1:
sectionName = NSLocalizedString(@"Trips", @"Trips");
break;
default:
sectionName = @"";
break;
}
return sectionName;
}
- (void) onSortSegment:(UISegmentedControl *)sender {
LogMethod();
dumpTrips();
sortSegment = sender.selectedSegmentIndex;
[self reloadTrips];
}
- (void) reloadTrips {
LogMethod();
dumpTrips();
trips = [[Database sharedInstance] getTrips];
trips = [trips sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
NSArray *trip1 = obj1;
NSArray *trip2 = obj2;
if (sortSegment==0) {
NSInteger trip1ID =[trip1[0] integerValue];
NSInteger trip2ID =[trip2[0] integerValue];
if (trip1ID>trip2ID) {
return NSOrderedAscending;
} else if (trip1ID<trip2ID) {
return NSOrderedDescending;
} else {
return NSOrderedSame;
}
} else if (sortSegment==1) {
NSString *name1 = trip1[1];
NSString *name2 = trip2[1];
return [name1 compare:name2 options:NSCaseInsensitiveSearch];
} else if (sortSegment==2) {
NSInteger trip1ID =[trip1[0] integerValue];
NSInteger trip2ID =[trip2[0] integerValue];
double tripLength1 = [[Database sharedInstance] getTripLength:trip1ID];
double tripLength2 = [[Database sharedInstance] getTripLength:trip2ID];
if (tripLength1>tripLength2) {
return NSOrderedAscending;
} else if (tripLength1<tripLength2) {
return NSOrderedDescending;
} else {
return NSOrderedSame;
}
}
return NSOrderedSame;
}];
[self.tableView reloadData];
}
@end
UIPopoverView由storybard-segue显示。在Parent-Tableview中只有这个代码:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"trips"]) {
TripsTableViewController *tripsTableViewController = segue.destinationViewController;
tripsTableViewController.mapView = [self mapView];
}
}
它是UINavigationViewContoller的一部分,其中没有代码。 我已经尝试将UIPopoverView的启动移动到工具栏中的额外调试按钮,该按钮使用故事板中的非特殊segue来启动UIPopoverView。结果相同。 如上所述,它只出现在应用程序用户(Pilots Atlas)报告的百分之几的设备上。它并没有出现在我的任何测试设备上(大约10种不同的测试设备)。
毫无疑问,alpha在任何地方都不会改变。查看左右NavigationBarButtons,它们已经显示为正常。