Make writing a habit together! This is the 14th day of my participation in the “Gold Digging Day New Plan · April More Text Challenge”. Click here for more details.
preface
Requirement: Use the current VC interface as the background image of another VC (push another background transparent view controller in the current view)
The content is displayed over another View Controller’s content
Payment details of the order
Publish the selected category of goods
Feedback page
Code card equipment (including electronic licensing, static licensing, licensing speaker all-in-one machine) add the qr code check and download functions
Payment details of the order
This interface is a separate payment plug-in
Implementation idea:
- The modal system at using styles: UIModalPresentationOverCurrentContext
– A presentation style where the content is displayed over another View controller’s content
`)
- Capture the current screen
I. Implementation scheme
It is recommended to use the system’s own modal style to achieve requirements, because the performance is better and the implementation is simple
1.1 Use the system’s modal style
To set modalPresentationStyle UIModalPresentationOverCurrentContext, and set the color mask
CategoryViewController *tmp = [CategoryViewController new];
tmp.modalPresentationStyle = UIModalPresentationOverCurrentContext;
// Set the mask color
[tmp view].backgroundColor = STModalWindowDefaultBackgroundColor;
[self.navigationController presentViewController:tmp animated:YES completion:^{
}];
Copy the code
The background color of the subview can be clearColor, or another color, as required.
- (void)viewDidLoad {
[super viewDidLoad];
// Set the VCView background color to clearColor
[self vcView].backgroundColor =[UIColor clearColor] ;
}
Copy the code
Settings Click mask to return to the previous screen
Set priority tableView click event, below the selected cell and click button events UIControlEventTouchUpInside
- (CRMSelectedWechantActivityTypeV *)vcView{
if(! _vcView) { CRMSelectedWechantActivityTypeV *tmp = [[CRMSelectedWechantActivityTypeV alloc] initWithViewModel:self.viewModel];
_vcView= tmp;
__weak __typeof__(self) weakSelf = self;
[self.view addSubview:tmp];
[tmp mas_makeConstraints:^(MASConstraintMaker *make) {
CGFloat CategoriesH =1* (142+12);
make.height.mas_equalTo(kAdjustRatio(78+CategoriesH+90));
make.left.equalTo(weakSelf.view).offset(kAdjustRatio(0));
make.bottom.equalTo(weakSelf.view);
make.right.equalTo(weakSelf.view).offset(-kAdjustRatio(0));
// Set the subview constraint (height)
make.height.equalTo(weakSelf.view).multipliedBy(0.45).offset(kAdjustRatio(self.viewModel.selectedplatProductCategories.count*50+50));
}];
UITapGestureRecognizer *cutTap = [[UITapGestureRecognizer alloc] init];
[[cutTap rac_gestureSignal] subscribeNext:^(id x) {
[weakSelf dismissViewControllerAnimated:YES completion:nil];
}];
[weakSelf.view addGestureRecognizer:cutTap];
UITapGestureRecognizer *cutTap1 = [[UITapGestureRecognizer alloc] init];
[[cutTap1 rac_gestureSignal] subscribeNext:^(id x) {
NSLog(Set tableView click event priority to lower than cell select event priority);
}];
cutTap1.cancelsTouchesInView = NO;// Set the click event priority of the tableView lower than the selected event of the cell
[tmp.tableView addGestureRecognizer:cutTap1];
}
return _vcView;
}
Copy the code
Effect: Publish the selected item category
Download address: download.csdn.net/download/u0…
The article addresses: kunnan.blog.csdn.net/article/det…
Video address: live.csdn.net/v/167208
Application scenarios of commodity Operation category selection view:
1. Select product categories when releasing products; 2. Merchants select business categories when entering products; 3
You can use the run API to control the modal style globally
Resources from CSDN download the complete demo source: download.csdn.net/download/u0… Flexible control mode shows the view style of the article: blog.csdn.net/z929118967/… More content please pay attention to the official number: iOS reverse
- (NSMutableArray *)OverCurrentContextClasss{
if(_OverCurrentContextClasss == nil){
_OverCurrentContextClasss = [NSMutableArray array];
/ /.. Publish merchandise - Select merchandise category
[_OverCurrentContextClasss addObject:@"ERPSelect_commodity_categoryViewController"];
// Image browser
[_OverCurrentContextClasss addObject:@"KNImageBrowserViewController"];
// Select wechat activities
[_OverCurrentContextClasss addObject:@"CRMSelectedWechantActivityTypeVC"];
}
return _OverCurrentContextClasss;
}
Copy the code
1.2 Intercepting the current view
Screenshots are automatically generated on the feedback page
Note: The screenshot is created before the bounce feedback page
【 principle article 】 (https://kunnan.blog.csdn.net/article/details/113444297)
1.3 Summary of the use of dismiss
Application 1: Customizing the WebViewController will cause the WebView controller to be killed after using the album
Question: A feature of Apple. When the modes are N viewcontrollers, you just dismiss one of them, all the modes after that try to, So that causes the H5 of the WebView in the MODAL UIViewController to pop up Camera/ImagePicker, When UIDocumentMenuViewController disappear will cause the WebView controller was also killed.
solution So make dismissViewControllerAnimated call time, or let UIDocumentMenuViewController find presentingViewController can.
To obtain demo source, please pay attention to the public number: iOS reverse
Github.com/zhangkn/KNU…
Application 2: To dismiss all the viewControllers out of the mode at once, just use presentingViewController to dismiss
[t setDissblock:^(id _Nonnull sender) {
[weakSelf.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}];
Copy the code
II. Pre-knowledge
2.1 Generation of TWO-DIMENSIONAL Code
Pod ‘LBXScan/LBXNative’,’~> 2.5′
self.iconV.image = [LBXScanNative createQRWithString:models.content4code QRSize:CGSizeMake(kAdjustRatio(180), kAdjustRatio(180))];
Copy the code
2.2 Save pictures to album
Blog.csdn.net/z929118967/…
- Requirements: Code equipment (including electronic licensing, static licensing, licensing speaker all – in – one machine) to add the qr code check and download functions
- The relationship between the view and the width and height of the saved image:
The closer the width of the view is to the width of the screen, the clearer the image.
The width of the saved view is 1:1 if it is the same as the width of the screen.
If the width of the saved view is less than the width of the screen, the image is enlarged at the width of the screen, but the width of the saved image is equal to the width of the screen.
- Add permission:
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Need access to your album, for payment code pictures to download</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>App will use your album permissions when customizing membership</string>
Copy the code
If no corresponding error information is added
#366012 SIGABRT
libsystem_kernel.dylib ___abort_with_payload
Copy the code
see also
Git branch Management tutorial
Mp.weixin.qq.com/s/-63si1cRx…