try to fix aboutView ok button

This commit is contained in:
TrueZhuanjia committed 2025-07-27 01:12:07 +08:00
1 parent 04ecd45f7c
commit 5fcfa84766
5 files changed
+18 -8

No files matched your search

+12 -2
View File
@@ -10,8 +10,10 @@
import SwiftUI import SwiftUI
@available(iOS 13.0, *) @available(iOS 13.0, *)
public struct AboutView: View { public struct AboutView: View {
@Environment(\.presentationMode) var presentationMode @Environment(\.presentationMode) var presentationMode
public var aboutVC:UIViewController
public var body: some View { public var body: some View {
VStack(spacing: 10) { VStack(spacing: 10) {
@@ -62,13 +64,12 @@ public struct AboutView: View {
Spacer() Spacer()
// OK 按钮 // OK 按钮
Button(SwiftLocalizationHelper.localizedString(forKey: "OK")) { Button(SwiftLocalizationHelper.localizedString(forKey: "OK")) {
presentationMode.wrappedValue.dismiss() aboutVC.dismiss(animated:true)
} }
.padding() .padding()
.background(Color.blue) .background(Color.blue)
.foregroundColor(.white) .foregroundColor(.white)
.frame(height: 46) .frame(height: 46)
//.frame(width: 100)
.cornerRadius(12) .cornerRadius(12)
} else { } else {
HStack(spacing: 20) { HStack(spacing: 20) {
@@ -94,6 +95,14 @@ public struct AboutView: View {
.cornerRadius(12) .cornerRadius(12)
.frame(height: 33) .frame(height: 33)
.frame(minWidth: 100)*/ .frame(minWidth: 100)*/
Button(SwiftLocalizationHelper.localizedString(forKey: "OK")) {
aboutVC.dismiss(animated:true)
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(12)
.frame(height: 33)
} }
.padding(.top, 10) .padding(.top, 10)
} }
@@ -101,3 +110,4 @@ public struct AboutView: View {
.padding() .padding()
} }
} }
+2 -2
View File
@@ -14,7 +14,8 @@ import SwiftUI
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
let hostingVC = UIHostingController(rootView: AboutView()) let hostingVC = UIHostingController(rootView: AboutView( aboutVC: self))
addChild(hostingVC) addChild(hostingVC)
hostingVC.view.translatesAutoresizingMaskIntoConstraints = false hostingVC.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(hostingVC.view) view.addSubview(hostingVC.view)
@@ -29,7 +30,6 @@ import SwiftUI
// 🎯 设置弹窗大小 // 🎯 设置弹窗大小
preferredContentSize = CGSize(width: 530, height: 450) preferredContentSize = CGSize(width: 530, height: 450)
//preferredContentSize = CGSize(width:150, height:120 )
// ⚠️ 一定要设置以下样式才会生效 preferredContentSize // ⚠️ 一定要设置以下样式才会生效 preferredContentSize
modalPresentationStyle = .formSheet modalPresentationStyle = .formSheet
@@ -26,7 +26,7 @@ static CGRect layoutViewBounds;
static OSCProfilesManager *_sharedManager = nil; static OSCProfilesManager *_sharedManager = nil;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
layoutViewBounds = viewBounds; layoutViewBounds = viewBounds;
NSLog(@"bounds width: %f, height: %f", layoutViewBounds.size.width, layoutViewBounds.size.height); // NSLog(@"bounds width: %f, height: %f", layoutViewBounds.size.width, layoutViewBounds.size.height);
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
_sharedManager = [[self alloc] init]; _sharedManager = [[self alloc] init];
}); });
+2 -2
View File
@@ -472,7 +472,7 @@ import UIKit
if vibrationOn { if vibrationOn {
vibrationGenerator.prepare() vibrationGenerator.prepare()
vibrationGenerator.impactOccurred() vibrationGenerator.impactOccurred()
print("vibrationInstance: \(vibrationGenerator)") // print("vibrationInstance: \(vibrationGenerator)")
} }
return indicatorBorder return indicatorBorder
@@ -864,7 +864,7 @@ import UIKit
if vibrationOn { if vibrationOn {
vibrationGenerator.prepare() vibrationGenerator.prepare()
vibrationGenerator.impactOccurred() vibrationGenerator.impactOccurred()
print("vibrationInstance: \(vibrationGenerator)") // print("vibrationInstance: \(vibrationGenerator)")
} }
CATransaction.commit() CATransaction.commit()
} }
@@ -1941,7 +1941,7 @@ static NSMutableSet* hostList;
// This function forces immediate decoding of the UIImage, rather // This function forces immediate decoding of the UIImage, rather
// than the default lazy decoding that results in janky scrolling. // than the default lazy decoding that results in janky scrolling.
-(void)deviceOrientationDidChange{ -(void)deviceOrientationDidChange{
if(self.collectionView.superview == nil) return; if(self.revealViewController.isStreaming || self.collectionView.superview == nil) return;
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
[self.collectionView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor], [self.collectionView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor],
[self.collectionView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor], [self.collectionView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor],