Questions tagged «ios»

iOS是在Apple iPhone,iPod touch和iPad上运行的移动操作系统。使用此标签[ios]来解决与iOS平台上的编程有关的问题。使用相关的标签[objective-c]和[swift]解决那些编程语言所特有的问题。


14
在UIWebView中更改用户代理
我有一项业务需要能够为嵌入式UIWebView定制UserAgent。(例如,如果用户使用的是应用的一个版本,而另一个版本,则我希望服务器做出不同的响应。) 是否可以像在Windows应用程序中的嵌入式IE浏览器那样自定义现有UIWebView控件中的UserAgent?

19
更改UITabBar的高度
我UITabBarController用作根视图,并且应用程序支持iOS 6及更高版本。项目类的层次结构如下。 UITabBarController - tab1 - UINavigationController - UIViewController - UIViewController . . - tab2 - UINavigationController - UIViewController - UIViewController . . . - tab3 - UIViewController - tab4 - UIViewController 我使用下面的代码来更改上面层次结构UITabBar中的一个UIViewControllers(位于里面UINavigationController)的高度。 CGRect tabbarFrame = self.tabBarController.tabBar.frame; tabbarFrame.size.height += 60; self.tabBarController.tabBar.frame = tabbarFrame; 但是它并没有改变高度。UITabBar以默认高度显示。尽管记录其值会打印更改的值,如下所示。 <UITabBar: 0xb528f60; frame = (0 431; …

13
从WKWebView获取所有cookie
使用来获取cookieUIWebView似乎很简单NSHTTPCookieStorage.sharedHTTPCookieStorage(),似乎WKWebView将cookie存储在其他位置。 我做了一些研究,然后从NSHTTPURLResponse对象中获取了一些Cookie 。但是,其中不包含WKWebView: func webView(webView: WKWebView, decidePolicyForNavigationResponse navigationResponse: WKNavigationResponse, decisionHandler: (WKNavigationResponsePolicy) -> Void) { if let httpResponse = navigationResponse.response as? NSHTTPURLResponse { if let headers = httpResponse.allHeaderFields as? [String: String], url = httpResponse.URL { let cookies = NSHTTPCookie.cookiesWithResponseHeaderFields(headers, forURL: url) for cookie in cookies { logDebug(cookie.description) logDebug("found cookie " + …

6
Swift-检查时间戳记是昨天,今天,明天还是X天之前
我正在尝试确定如何确定给定的时间戳发生在今天还是+1 / -1天。本质上,我想做这样的事情(伪代码) IF days_from_today(timestamp) == -1 RETURN 'Yesterday' ELSE IF days_from_today(timestamp) == 0 RETURN 'Today' ELSE IF days_from_today(timestamp) == 1 RETURN 'Tomorrow' ELSE IF days_from_today(timestamp) < 1 RETURN days_from_today(timestamp) + ' days ago' ELSE RETURN 'In ' + days_from_today(timestamp) + ' ago' 但至关重要的是,它必须在Swift中,并且我在NSDate / NSCalendar对象方面苦苦挣扎。我首先计算出时差,如下所示: let calendar = NSCalendar.currentCalendar() …
70 ios  swift  nsdate  nscalendar 


3
Swift枚举继承
您可以在Swift中继承枚举吗?关于枚举继承,应注意哪些规则? 以下测试代码: enum TemperatureUnit: Int { case Kelvin, Celcius, Farenheit } enum TemperatureSubunit : Temperature { } 产生 error: type 'TemperatureSubunit' does not conform to protocol 'RawRepresentable'

6
带有CocoaPods,Swift 3和Xcode 8的ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES是什么
安装cocoapods并添加pod "SwiftCarousel"到pod文件并取消注释平台后:ios,“ 9.0”,我收到此错误 ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES 我该怎么办? mohammed.elias$ pod install Analyzing dependencies Downloading dependencies Installing SwiftCarousel (0.8.0) Generating Pods project Integrating client project [!] Please close any current Xcode sessions and use `scrollView.xcworkspace` for this project from now on. Sending stats Pod installation complete! There is 1 dependency from the Podfile and …
70 ios  swift3  cocoapods  xcode8 


8
自动布局(约束)在父视图中居中2个并排视图
我试图弄清楚如何使用自动布局(iOS6)和约束来做到这一点。 基本上,我的大视野在底部分为两个部分。在这些部分(当前为子视图)中,我具有图像视图和标签。我想用可变长的文本在两边居中。 我的头主要围绕自动布局,但是我不确定最好的方法。我倾向于认为在IB中是不可能的,但是在代码中。 继续尝试解决这个问题,但与此同时,这是我要创建的示例。

10
iOS6 UDID-identifierForVendor相对于identifierForAdvertising有什么优势?
苹果正在更改其iOS6的隐私设置,并弃用设备UUID(UDID)。根据WWDC的介绍和文档,UIDevice该类中有UDID的两个替代品: -identifierForVendor 同一开发人员的应用之间的ID相同。 删除该团队ID的最后一个应用后删除。 备份。 -identifierForAdvertising 设备独有的。 适用于所有应用程序;用于广告-iAd已从UDID转换为iOS 6及更高版本。 使用“删除所有内容和设置”重置。 备份。 在我看来,这-identifierForVendor是次等的,-identifierForAdvertising因为它将在上次从供应商处卸载应用程序时重置并通过“擦除所有内容和设置”来重置。 相比-identifierForVendor有什么优势-identifierForAdvertising?
69 ios  privacy  udid  ios6 

2
如果启用了模块,则tgmath.h不起作用
在处理arm64时,我考虑使用tgmath.h来处理CGFloat typedef float/double混乱。 这个答案对如何使用它有很好的描述,除了它对我一点都不起作用。无论如何,我的代码仍在调用math.h函数。 花了一些时间查看所有项目编译器设置后,我发现禁用“模块”功能(@import vs #import-iOS 7)可以使所有功能正常工作。更具体地说,在项目设置中的选项被称为Enable Modules(C and Objective-C)在Apple LLVM 5.1 - Language - Modules下拉列表中。 要查看此问题的快速示例,请下载使用tgmath的项目,例如MBProgressHUD,并查看启用模块项目设置时会发生什么。该tgmath.h呼叫会被替换成普通math.h电话。 我的问题是: 为什么模块会阻止tgmath正确导入? 有没有一种解决方法,可以同时使用tgmath和模块?我仍然希望能够使用它们。

5
解析来自didReceiveRemoteNotification:fetchCompletionHandler的警告
从parse.com添加以下代码后,我得到一个错误: - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { if (application.applicationState == UIApplicationStateInactive) { [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo]; } } 我不太了解发生了什么,但是我在日志中收到以下警告: 您已经实现了-[application:didReceiveRemoteNotification:fetchCompletionHandler:],但仍需要在Info.plist中的受支持的UIBackgroundModes列表中添加“ remote-notification”。 我认为在您的plist文件中添加即可UIBackgroundModes - remote-notification解决此问题, 但是,当我这样做时,它将改为以下内容: Required Background Modes -> App downloads content in response to push notifications 我的应用程序不执行哪个操作,因此我对于为什么要首先执行此操作感到困惑。



By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.