我正在使用Xcode 8.2.1,每当将视图设置为较小的设备时,我都会在设备的右侧和底部获取这些背面边框XIB文件。每当我选择iPhone 7 Plus,然后在iPhone 7上运行时,界面的一部分被推离屏幕的右侧和底部,也存在这样的问题。目前所有东西都在Objective-C中编码。Xcode Xib - iOS模拟器的黑色边框右侧和底部
更新:
主屏幕。
代码:
RootViewController的
#import "RootViewController.h"
#import "AppDelegate.h"
#import "DetailViewController.h"
- (void)viewDidLoad {
[super viewDidLoad];
if(CurrentLevel == 0) {
NSArray *tempArray = [[NSArray alloc] init];
self.tableDataSource = tempArray;
[tempArray release];
AppDelegate *AppDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
self.tableDataSource = (AppDelegate.data)[@"Rows"];
self.navigationItem.title = @"Title";
}
else
self.navigationItem.title = CurrentTitle;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *dictionary = (self.tableDataSource)[indexPath.row];
NSArray *Children = dictionary[@"Children"];
if(Children.count == 0) {
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController animated:YES];
dvController.CurrentTitle = dictionary[@"Title"];
[dvController release];
}
else {
RootViewController *rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];
rvController.CurrentLevel += 1;
rvController.CurrentTitle = dictionary[@"Title"];
[self.navigationController pushViewController:rvController animated:YES];
rvController.tableDataSource = Children;
[rvController release];
}
}
的AppDelegate
#import "AppDelegate.h"
#import "RootViewController.h"
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSString *Path = [NSBundle mainBundle].bundlePath;
NSString *DataPath = [Path stringByAppendingPathComponent:@"Master.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
self.data = tempDict;
[tempDict release];
[window setRootViewController:navigationController];
[window makeKeyAndVisible];
}
DetailViewController
#import "DetailViewController.h"
#import "AppDelegate.h"
@implementation DetailViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
当您的视图小于设备的屏幕时会发生这种情况。您应该启用自动布局并添加限制以适合任何设备。 – Calc91
@ Calc91我已经启用了自动布局,并且在任何地方都可以设置约束条件。 – Number1