我正在使用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