Reputation: 391
I'm working with Xcode 8.2.1 and I'm getting these back borders on the right and bottom sides of the device whenever I set the view as a smaller device in the XIB file. There is also the problem where whenever I select iPhone 7 Plus and then run on a iPhone 7 that part of the interface is pushed off the right and bottom of the screen. Everything is currently coded in Objective-C.
Update:
Main screen.
Code:
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;
}
}
Upvotes: 0
Views: 364
Reputation: 4212
Having "constraints set everywhere you can" is probably not what you want. It looks like you have set an explicit width and height. Remove all your current constraints and instead set a top, bottom, leading, and trailing constraint with a value of 0 and uncheck 'constrain to margins' (if you want the tableview to fill the view).
EDIT:
After some discussion in chat, I've realize that this has nothing to do with AutoLayout constraints. Rather, since you are using a XIB for your main window, it is being sized explicitly to the size set in the XIB. All you need to do to have it be sized correctly is tell it what the size of your screen is. Anywhere in applicationDidFinishLaunching:
, just add [window setFrame:UIScreen.mainScreen.bounds];
and it will resize to the size of the device's screen.
Upvotes: 2