|
@@ -29,6 +29,9 @@
|
|
|
@property (nonatomic, strong) UILabel * searchResultLabel;
|
|
|
@property (nonatomic, strong) UILabel * pageLabel;
|
|
|
|
|
|
+@property (nonatomic, strong) UILabel *titleLabel;
|
|
|
+@property (nonatomic, strong) UIButton *backBtn;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation CPDFSearchResultsViewController
|
|
@@ -52,8 +55,8 @@
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
// Do any additional setup after loading the view.
|
|
|
- [self changeleftItem];
|
|
|
- self.title = NSLocalizedString(@"Search Results", nil);
|
|
|
+// [self changeleftItem];
|
|
|
+// self.title = NSLocalizedString(@"Search Results", nil);
|
|
|
|
|
|
self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
|
|
|
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
@@ -81,20 +84,80 @@
|
|
|
[self.searchResultView addSubview:self.pageLabel];
|
|
|
[self.view addSubview:self.searchResultView];
|
|
|
|
|
|
+ [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
|
|
|
+
|
|
|
+
|
|
|
+ self.titleLabel = [[UILabel alloc] init];
|
|
|
+ self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
|
|
|
+
|
|
|
+ self.titleLabel.text = NSLocalizedString(@"Search Results", nil);
|
|
|
+ self.titleLabel.font = [UIFont systemFontOfSize:20];
|
|
|
+ self.titleLabel.adjustsFontSizeToFitWidth = YES;
|
|
|
+ [self.view addSubview:self.titleLabel];
|
|
|
|
|
|
+ self.backBtn = [[UIButton alloc] init];
|
|
|
+ self.backBtn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
|
|
|
+ [self.backBtn setImage:[UIImage imageNamed:@"CPDFEditClose" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
|
|
|
+ [self.backBtn addTarget:self action:@selector(buttonItemClicked_back:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:self.backBtn];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)buttonItemClicked_back:(UIButton *)button {
|
|
|
+ [self dismissViewControllerAnimated:YES completion:^{
|
|
|
+
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
+//- (void)viewWillLayoutSubviews {
|
|
|
+//
|
|
|
+// if (@available(iOS 11.0, *)) {
|
|
|
+//
|
|
|
+// self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, 50);
|
|
|
+//
|
|
|
+// self.tableView.frame = CGRectMake(self.view.safeAreaInsets.left, 62, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height - 92);
|
|
|
+// self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60, 5, 50, 50);
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, 50);
|
|
|
+// self.tableView.frame = CGRectMake(0, 62, self.view.frame.size.width, self.view.frame.size.height - 92);
|
|
|
+// self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60, 5, 50, 50);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//}
|
|
|
+
|
|
|
+- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
|
|
+ [super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
|
|
|
+ [self updatePreferredContentSizeWithTraitCollection:newCollection];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection
|
|
|
+{
|
|
|
+ self.preferredContentSize = CGSizeMake(self.view.bounds.size.width,self.view.bounds.size.height * 0.9);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
- (void)viewWillLayoutSubviews {
|
|
|
[super viewWillLayoutSubviews];
|
|
|
|
|
|
if (@available(iOS 11.0, *)) {
|
|
|
- self.tableView.frame = CGRectMake(self.view.safeAreaInsets.left, self.view.safeAreaInsets.top +28, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height - self.view.safeAreaInsets.bottom- self.view.safeAreaInsets.top - 28);
|
|
|
+ self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, 50);
|
|
|
+ self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60, 5, 50, 50);
|
|
|
+ self.tableView.frame = CGRectMake(self.view.safeAreaInsets.left, self.view.safeAreaInsets.top +28 + 50, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height - self.view.safeAreaInsets.bottom- self.view.safeAreaInsets.top - 50);
|
|
|
+ self.searchResultView.frame = CGRectMake(self.view.safeAreaInsets.left, self.view.safeAreaInsets.top + 50, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 28);
|
|
|
+ self.searchResultLabel.frame = CGRectMake(70, 4, 200, 20);
|
|
|
+ self.searchResultLabel.text = [NSString stringWithFormat:@"%zd results found",self.resultArray.count];
|
|
|
+ self.pageLabel.frame = CGRectMake(self.view.frame.size.width - 50, 4, 40, 20);
|
|
|
+ } else {
|
|
|
+ self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, 50);
|
|
|
+ self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60, 5, 50, 50);
|
|
|
self.searchResultView.frame = CGRectMake(self.view.safeAreaInsets.left, self.view.safeAreaInsets.top, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, 28);
|
|
|
self.searchResultLabel.frame = CGRectMake(20, 4, 200, 20);
|
|
|
self.searchResultLabel.text = [NSString stringWithFormat:@"%zd results found",self.resultArray.count];
|
|
|
self.pageLabel.frame = CGRectMake(self.view.frame.size.width - 50, 4, 40, 20);
|
|
|
- } else {
|
|
|
- self.tableView.frame = self.view.bounds;
|
|
|
+// self.view.bounds
|
|
|
+ self.tableView.frame = CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y + 50 + 28, self.view.bounds.size.width, self.view.bounds.size.height - 50 - 28);
|
|
|
|
|
|
}
|
|
|
}
|