现在,AppDelegate和SceneDelegate从SwiftUI删除,你在哪里我把我以前在代码SceneDelegate和AppDelegate,火力地堡配置为前?
所以我目前在我的代码中有这个代码AppDelegate:
我现在应该把这段代码放在哪里?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseConfiguration.shared.setLoggerLevel(.min)
FirebaseApp.configure()
return true
}
Run Code Online (Sandbox Code Playgroud) 我有这个div,我想显示title当我将鼠标悬停在titlediv上时.问题是,即使我将鼠标悬停在div的边缘,我也会获得悬停效果.所以当我将鼠标悬停在它上面时,div被视为一个正方形,而不是一个圆圈.这在Firefox上运行得很好,但在Chrome和Safari上却不行.
小提琴:http://jsfiddle.net/roeg629c/2/
注意:我不想更改图像的宽高比.图像应该是100% of the parent height.
HTML
<div class="video_wrap update" video_name="rikthejmna">
<div class="related img_wrap"><img src="http://img.youtube.com/vi/XyzYVpJGRG8/hqdefault.jpg"></div>
<div class="title">rikthejm na</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.video_wrap {
width: 232px;
height: 232px;
display: inline-block;
border-radius: 116px;
overflow: hidden;
margin: 10px;
position: relative;
z-index: 2;
}
.img_wrap img {height: 100%}
.related {height: 100%;}
.title {
position: relative;
top: -50px;
left: 0px;
background: #fff;
height: 50px;
opacity: .5;
color: #f8008c;
font-size: 12px;
text-align: center;
line-height: 50px;
overflow: hidden; …Run Code Online (Sandbox Code Playgroud) 我有一个圆形div,它有一个圆形图像和一个标题在底部whith opacity: 0.5;悬停不透明度应该变为1.它在所有桌面浏览器和Firefox for iOS上都很好,但它在Safari和Chrome for iOS上都不起作用.
小提琴:https://jsfiddle.net/a10rLbnL/2/
HTML:
<div class="video_wrap update">
<div class="content">
<div class="img_wrap"><img src="https://i.ytimg.com/vi/0HDdjwpPM3Y/hqdefault.jpg"></div>
<div class="title_wrap"><div class="title">bang bang</div></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.video_wrap {
display: inline-block;
width: 30%;
padding-bottom: 30%;
margin: 0 1%;
position: relative;
vertical-align: top;
}
.content {
position: absolute;
height: 100%;
width: 100%;
}
.img_wrap {
height: 100%;
border-radius: 120px;
overflow: hidden;
}
.title_wrap {
line-height: 50px;
top: -50px;
height: 50px;
position: relative;
left: 0px;
background: #fff;
color: #f8008c;
font-size: 12px; …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 SwiftUI 2.0 中实现远程推送通知,但没有 AppDelegate。我知道我可以通过以下方式提供一个@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate,但我了解到不建议这样做。
我尝试通过 Firebase Cloud Messaging 触发通知,但没有收到任何测试通知。我刚刚弹出了允许通知的窗口,仅此而已。
我没有收到任何错误或其他东西......什么也没有真正发生。
我错过了什么吗?
考试:
Firebase registration token: Optional("fwRsIKd7aUZeoLmmW5b4Zo:APA91bHrVvArS-mLZMEkdtzTxhRUuMWVgHNKXdLethAvR3Fa3h_RmAcdOz_jJzp1kDsEEtcvbnAFUn9eh9-cUSCTy9jBibbFoR2xngWdzWCvci1_iLQJtHtCjxk-C02CkVUDl7FX8esp")
这是我的代码:
import SwiftUI
import Firebase
import OSLog
@main
struct Le_fretApp: App {
@StateObject var sessionStore = SessionStore()
@StateObject var locationManagerService = LocationManagerService()
@StateObject var userViewModel = UserViewModel()
var notificationsService = NotificationsService()
init() {
UIApplication.shared.delegate = NotificationsService.Shared
FirebaseConfiguration.shared.setLoggerLevel(.min)
notificationsService.register()
FirebaseApp.configure()
notificationsService.setDelegate()
}
var body: some Scene {
WindowGroup {
TabViewContainerView()
.environmentObject(sessionStore)
.environmentObject(userViewModel)
.environmentObject(locationManagerService)
.onAppear {
sessionStore.listen()
userViewModel.listen()
}
}
} …Run Code Online (Sandbox Code Playgroud) apple-push-notifications ios swift firebase-cloud-messaging swiftui
我MapKit用来显示两个注释和它们之间的距离。一切正常,但我一直在控制台上收到此错误。
MobileGestalt.c:1647:无法检索区域信息
有人知道是什么原因造成的吗?可能是.plist文件中的某些权限
这是完整的控制台输出:
2019-11-10 00:21:41.419108+0100 Post DACH[20420:264466] Metal API Validation Enabled
2019-11-10 00:21:41.567416+0100 Post DACH[20420:264466] libMobileGestalt MobileGestalt.c:1647: Could not retrieve region info
我的代码:
struct MapView: UIViewRepresentable {
var requestLocation: CLLocationCoordinate2D
var destinationLocation: CLLocationCoordinate2D
private let mapView = WrappableMapView()
func makeUIView(context: UIViewRepresentableContext<MapView>) -> MKMapView {
mapView.delegate = mapView
return mapView
}
func updateUIView(_ uiView: MKMapView, context: UIViewRepresentableContext<MapView>) {
let requestAnnotation = MKPointAnnotation()
requestAnnotation.coordinate = requestLocation
requestAnnotation.title = "Package"
uiView.addAnnotation(requestAnnotation)
let destinationAnnotation = MKPointAnnotation()
destinationAnnotation.coordinate = destinationLocation …Run Code Online (Sandbox Code Playgroud) 我有一个视图,其中显示我的消息列表。每当添加新消息时,我想滚动到底部。我正在尝试添加一个onChange事件,ForEach但这会破坏我的代码并出现一些奇怪的错误:
在“Array”上引用实例方法“onChange(of:perform:)”要求“Message”符合“Equatable”
有时
编译器无法在合理的时间内对该表达式进行类型检查;尝试将表达式分解为不同的子表达式
当我删除onChange一切都符合要求时。
这是Message模型:
struct Message: Identifiable {
var id = UUID()
var text: String
var createdAt: Date = Date()
var senderID: String
var seen: Bool
init(dictionary: [String: Any]) {
self.text = dictionary["text"] as? String ?? ""
self.senderID = dictionary["senderID"] as? String ?? ""
self.seen = dictionary["seen"] as? Bool ?? false
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?
'对于每个
struct MessagesView: View {
@ObservedObject var messagesViewModel: MessagesViewModel
var body: some View {
VStack { …Run Code Online (Sandbox Code Playgroud) 我有一个Horizontal UICollectionView在我的应用程序上,我想在用户到达UICollectionView的末尾(或接近结尾)时加载更多数据,同时在左侧拖动.
我正在使用Swift 4.我找到了一些Swift 3解决方案,但它们对我不起作用.
我目前的代码是:
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.videoViewModel.images.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCell", for: indexPath) as! CollectionViewCell
cell.imgImage.image = self.videoViewModel.images[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
updateVideo(data: self.videoViewModel.relatedVideos[indexPath.row])
}
Run Code Online (Sandbox Code Playgroud) 我有一个进度条,有两个孩子(部分).每当这些孩子都徘徊时,进步及其子女的总高度就会发生变化.我设法解决了第一个使用的孩子,next sibling selector但我找不到第二个孩子的解决方案(黄色部分).到目前为止,我已经使用jQuery解决了这个问题,但我想在纯CSS中做到这一点.
小提琴:https://jsfiddle.net/zfh263r6/5/
$('#start').on({
mouseenter: function () {
//$(this).css('height', '4px');
//$( 'progress' ).css('height', '4px');
},
mouseleave: function () {
//$(this).css('height', '');
// $( 'progress' ).css('height', '');
}
});Run Code Online (Sandbox Code Playgroud)
#progress_wrap {
position: relative;
height: 4px; /*max height of progress*/
background: #f3f3f3;
}
progress {
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
width: 100%;
border:none;
height: 2px;
transition:all .25s ease-in;
cursor: pointer;
background-color: #fff;
position: absolute;
top: 0;
left: 0;
display: block;
}
progress:hover, progress:hover + #start …Run Code Online (Sandbox Code Playgroud)我正在尝试将 Crashlytics 集成到我的应用程序和 5. 步骤中,它说:
仅限 Xcode 10 或更高版本:将应用的 dSYM 位置添加为输入文件,使 Crashlytics 能够更快地为大型应用自动生成 dSYM。例如:
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}
我将此路径复制/粘贴到我的输入文件以及这个路径 $(SRCROOT)/$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)
使用 dSYM 文件将调试信息设置为 DWARF。
应该${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}是这样还是这是一个动态路径,我需要用我当前的 DSYM 文件路径替换它?
我已经在我的 SwiftUI 应用程序中实现了推送通知,一切似乎都工作正常。如您所知,没有 AppDelegate 但我们仍然可以使用@UIApplicationDelegateAdaptor.
但是我不喜欢这种方法,我想知道是否有一种方法可以在没有 AppDelegate 的情况下实现此方法?
class AppDelegate: NSObject, UIApplicationDelegate {
private var gcmMessageIDKey = "gcmMessageIDKey"
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
Messaging.messaging().delegate = self
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(options: authOptions, completionHandler: {_, _ in })
application.registerForRemoteNotifications()
return true
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
// If you are …Run Code Online (Sandbox Code Playgroud) push-notification apple-push-notifications ios swift swiftui