我在我的Macbook Air上运行我的应用程序和我的Iphone 6s,下面的图像是我浏览应用程序中的所有UI后的内存使用情况.在这两个场景中,我执行了类似的任务和持续时间.为什么模拟器的内存使用量比实际设备高得多.即使设备内存使用情况似乎合理,我是否应该担心?
在展示或解雇VC时,我不想继续隐藏和显示tabBar,因为它会造成糟糕的用户体验.相反,我希望在标签栏上直接显示下一个VC,这样当我通过从左向右缓慢拖动来关闭nextVC时,我可以看到隐藏在视图后面的tabBar(如下图所示)
请注意,我的应用程序有两个选项卡,其中包含两个与之关联的VC(VCA,VCB).两个VC都嵌入了导航栏.VCA分段为VCA1,VCB分段为VCB1.目前,在VCA和VCB内部,我调用以下函数来查看viewWillappear(下面的代码)时的一些隐藏和取消隐藏.
self.navigationController?.showViewController(vc, sender: self)
Run Code Online (Sandbox Code Playgroud)
// Inside ViewWillAppear Only reappear the tab bar if we successfully enter Discover VC (To prevent drag back half way causing tab bar to cause comment entry to be floating). This code check if we have successfully enters DiscoverVC
if let tc = transitionCoordinator() {
if tc.initiallyInteractive() == true {
tc.notifyWhenInteractionEndsUsingBlock({(context: UIViewControllerTransitionCoordinatorContext) -> Void in
if context.isCancelled() {
// do nothing!
}
else {
// not cancelled, do it
self.tabbarController.tabBar.hidden = false
}
})
} …Run Code Online (Sandbox Code Playgroud) 我的代码在下面显示的函数中崩溃了。该功能用于检查我是否可以访问互联网。我想知道崩溃意味着什么以及如何防止它?
func connectionStatus() -> ReachabilityStatus {
var zeroAddress = sockaddr_in()
zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
zeroAddress.sin_family = sa_family_t(AF_INET)
guard let defaultRouteReachability = withUnsafePointer(&zeroAddress, {
SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0))
}) else {
return .Unknown
}
var flags : SCNetworkReachabilityFlags = []
if !SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags) {
return .Unknown
}
return ReachabilityStatus(reachabilityFlags: flags)
}
Run Code Online (Sandbox Code Playgroud)
如果用户在开始时不允许访问相册,我会弹出一个带有取消和设置可供选择的弹出窗口。如果他选择设置,它会将他带到设置页面,在那里他可以为应用程序启用相机和照片库。但是,一旦用户在设置中切换相机或照片库开关,我的应用程序就会崩溃,并显示“来自调试器的消息:由于信号 9 而终止”打印输出。下面是我的弹出窗口的代码
@IBAction func cameraBarBtnPress(sender: AnyObject) {
let photoAuthStatus = PHPhotoLibrary.authorizationStatus()
switch photoAuthStatus {
case .Authorized:
presentFusumaCameraVC()
case .Denied, .Restricted :
showNeedPhotoAlbumAccessPopup()
case .NotDetermined:
PHPhotoLibrary.requestAuthorization({ (authStatus: PHAuthorizationStatus) in
switch authStatus {
case .Authorized:
self.presentFusumaCameraVC()
case .Denied, .Restricted :
self.showNeedPhotoAlbumAccessPopup()
case .NotDetermined:
print("Shouldnt get to here")
}
})
}
}
func showNeedPhotoAlbumAccessPopup() {
let alertController = UIAlertController(title: "Enable Photo Album Access", message: "", preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .Default, handler: nil)
let settingsAction = UIAlertAction(title: "Settings", style: …Run Code Online (Sandbox Code Playgroud) 我的应用程序上有条款和条件(TOC)部分.我想要实现的是从互联网上下载TOC并将其加载到屏幕上供用户使用.因为我不知道任何html/web的东西,我目前正在做的是将所有文本放在我的firebase上,并使用以下代码在textView中显示
DataService.ds.REF_TERMSOFSERVICE.observeEventType(.Value) { (snapshot: FIRDataSnapshot) in
if let termsOfService = snapshot.value as? String {
self.mainTextView.text = termsOfService
}
}
Run Code Online (Sandbox Code Playgroud)
但是,此方法仅将文本显示为纯文本而不进行任何格式设置(换行,粗体,字体,字体大小).
我想知道,有没有办法实现我想要的类似下面的图像,我可以有一些格式而不做一些web/Html的东西?(在这个阶段我只知道斯威夫特)?
我的SPA使用React作为前端,使用laravel API作为后端。
当用户登录时(通过axios和api),api将返回访问(承载者令牌)作为响应。我使用react-cookie框架将访问令牌作为cookie存储在浏览器中。该cookie将被读取并用于以后的任何请求。
这是正确的方法吗?Cookie数据不只是浏览器中可以被任何攻击者轻易获得的东西吗?由于它只是一个文件,因此可以放在计算机的某个位置。
是什么阻止了攻击者获取该Cookie,冒充该用户并开始执行需要身份验证的操作?
该令牌的使用寿命为1年。仅在用户每次登录时才会刷新。我知道,如果将寿命设置得较短,它将更加安全。但是,这是否意味着用户将不得不不断登录?
-----更新-----
我不确定所提供的解决方案是否回答了我的问题。SPA应用程序是基于前端的,并且该请求可以来自任何地方,例如邮递员,移动应用程序或希望与我的后备服务器通信的任何第三方设备。因此,这些设备需要一种在本地存储一些访问令牌以用于将来任何请求的方法。
我知道这可能发生的唯一方法是服务器将一些身份验证令牌发送给请求者,并将其存储在某个地方以用于下一个请求。
在这种情况下,我不确定CSRF令牌或其他任何方式是否可以帮助我解决问题?
就像facebook一样,如果我清除缓存,则必须重新登录。这意味着facebook正在我的位置计算机上存储一些东西,以便下次可以自动对我进行身份验证
cookies csrf csrf-protection single-page-application bearer-token
我有两个标签,Label1 和 Label2。我想创建一个函数,通过为两个标签创建 UITTapRecognizer,使用传递参数的选择器调用相同的函数来打印出哪个标签被点击。下面是很长的路要走,虽然杂乱但有效。如果我知道如何将参数 (Int) 传递给选择器,它会更清晰。
let topCommentLbl1Tap = UITapGestureRecognizer(target: self, action: #selector(DiscoverCell().doubleTapTopComment1))
topCommentLbl1Tap.numberOfTapsRequired = 2
topCommentLbl1.userInteractionEnabled = true
topCommentLbl1.addGestureRecognizer(topCommentLbl1Tap)
let topCommentLbl2Tap = UITapGestureRecognizer(target: self, action: #selector(DiscoverCell().doubleTapTopComment2))
topCommentLbl2Tap.numberOfTapsRequired = 2
topCommentLbl2.userInteractionEnabled = true
topCommentLbl2.addGestureRecognizer(topCommentLbl2Tap)
func doubleTapTopComment1() {
print("Double Tapped Top Comment 1")
}
func doubleTapTopComment2() {
print("Double Tapped Top Comment 2")
}
Run Code Online (Sandbox Code Playgroud)
有没有办法修改选择器方法,这样我就可以做类似的事情
func doubleTapTopComment(label:Int) {
if label == 1 {
print("label \(label) double tapped")
}
Run Code Online (Sandbox Code Playgroud) 我刚刚使用"ng new appName"创建了一个新的角度应用程序,并放入了一些按钮(来自ng-bootstrap).我想尝试部署到aws来检查它.但是,当我运行build -prod时,生成的dist文件(vendor.a9e57aafdd6abc88b94a.bundle.map)之一是7.7mb.这是文件的屏幕截图.解决此问题的最佳方法是什么,以便用户在加载时不必下载那么大的文件?
我刚刚阅读了Angular 2 AOT文档,并提出了一些问题
文档明显倾向于AOT优于JIT,并提到了关于AOT如何更好的所有好东西.如果是这种情况,为什么AOT不是默认构建而不是ng build --prod --aot
文档详细介绍了如何设置它.会ng build --prod --aot足够好,忽略所有这些设置吗?
我的导航栏 (app.component.html) 上有一个按钮,我只想在用户登录时显示该按钮。这是我当前的方法,但由于稍后解释的明显原因而不起作用。我想知道如何修改它才能工作。
在我的 app.component.html 中,我有以下按钮
<button *ngIf="isCurrentUserExist">MyButton</button>
Run Code Online (Sandbox Code Playgroud)
在我的 app.component.ts 中,我尝试将变量 isCurrentUserExist 绑定到一个函数,如果用户存在则返回 true。我相信这就是问题所在,因为此代码仅在 OnInit 处执行一次,而不是以某种方式保持视图更新
ngOnInit() {
this.isCurrentUserExist = this.userService.isCurrentUserExist();
}
Run Code Online (Sandbox Code Playgroud)
作为参考,在我的 UserService.ts 中
export class UserService {
private currentUser: User
constructor(private http: Http,private angularFire: AngularFire) { }
getCurrentUser(): User {
return this.currentUser
}
setCurrentUser(user: User) {
this.currentUser = user;
}
isCurrentUserExist(): boolean {
if (this.currentUser) {
return true
}
return false
}
}
Run Code Online (Sandbox Code Playgroud)
有关我的应用程序的更多信息...在用户不存在时启动时,我有一个登录屏幕(登录组件)。当用户登录时,它会转到 firebase 并获取用户信息(异步)并将其存储到我的用户服务中
setCurrentUser(user: User)
Run Code Online (Sandbox Code Playgroud)
因此,此时,我想更新导航栏中的按钮(存在于 app.component.html 中)并显示该按钮。
我可以做什么来实现这个目标?
ios ×6
swift ×5
angular ×3
angular-cli ×1
angular2-aot ×1
bearer-token ×1
cookies ×1
csrf ×1
firebase ×1
html ×1
iphone ×1
jit ×1
memory ×1
objective-c ×1
selector ×1
simulator ×1
typescript ×1
xcode ×1