我已经使用两个操作按钮注册了推送和本地通知:action1和action2.收到通知后,我可以看到两者,也可以根据操作ID采取措施.但是,我的一个用例要求我在安排本地通知之前隐藏一个或两个操作按钮.我可以在运行时这样做吗?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Run Code Online (Sandbox Code Playgroud)
在这个方法中,我正在注册带有2个操作按钮的通知.
我看到,根据上下文,我们可以定义可变数量的动作按钮.但是,上下文是预定义的而不是用户定义的.
objective-c push-notification ios uilocalnotification action-button
我需要帮助。
我像 tihs 一样使用 sd_setImageWithURL
self.downloadButton.addTarget(self, action: #selector(self.stopDownloading), forControlEvents: .TouchUpInside)
self.imageView.sd_setImageWithURL(NSURL(string:myURL!)!, placeholderImage: UIImage(named: "placeHolderImage"), options: SDWebImageOptions.ProgressiveDownload , progress: {
(receivedSize: Int!, expectedSize: Int!) in
if(receivedSize > 0 )
{
self.percentString = String(format: "%.0f",(Float(receivedSize) / Float(expectedSize) * 100))
[self.downloadProgress.setProgress(Float(receivedSize) / Float(expectedSize), animated: true)]
self.downloadStateLabel.text = "\(receivedSize/1000000) / \(expectedSize/1000000)MB (\(self.percentString)%)"
NSLog("%@", self.percentString)
}
}, completed: {
(image, error, cacheType, url) in
NSLog("Completed'");
})
Run Code Online (Sandbox Code Playgroud)
func stopDownloading(sender: AnyObject)
{
NSLog("stopDownloading Clicked")
self.imageView.sd_cancelCurrentImageLoad()
}
Run Code Online (Sandbox Code Playgroud)
当我单击按钮时,我可以在 stopDownloading 函数中得到日志“stopDownloading Clicked”,但 sd_cancelCurrentImageLoad() 不起作用。
只要继续下载,我就可以获得已完成的日志。
如何停止下载或取消正在进行的 sd_setImageWithURL ?
谢谢。
我访问了这个链接 -
MyClass不可用:找不到此类的Swift声明 - 仅发布版本
添加链接或嵌入式Swift框架:'MyClass'不可用:找不到此类的Swift声明
但上述链接都没有帮助我解决我的问题.
我正在使用objective-c开发一个应用程序,在应用程序中我正在集成ios-charts,其框架是在swift中开发的.我已经合并了README文件中给出的项目.集成后,我创建了一个MyClass.swift文件,然后继承了MyClass.swift文件,其中包含一个在.But中定义的Class charts.framework.这是一个错误的上升
'Class'不可用:找不到此类的Swift声明
有没有人帮我解决这个错误?有什么建议??
我正在尝试将快速字典数组传递给 NSMutableArray。但我收到错误“无法将 [[String : Anyobject?]] 类型的值转换为预期的参数类型 NSMutableArray”。下面是代码:
var ary : [[String:AnyObject?]] = []
var mutableDictionary = [String: AnyObject?]()
for c in buffer {
mutableDictionary.updateValue(c.Name, forKey: "name")
mutableDictionary.updateValue(c.Number, forKey: "phoneNumber")
mutableDictionary.updateValue(c.id, forKey: "id")
ary.append(mutableDictionary)
}
Run Code Online (Sandbox Code Playgroud)
现在将这个“ary”作为 NSMutableArray 传递给 Objective C 方法!
Manager.sharedInstance().List(ary)
Run Code Online (Sandbox Code Playgroud) 我将我的价值存储在核心数据中并在BarChart上显示.我的类别金额为8.5和420.10.
但条形图的显示是8和420.我应该如何设置十进制值?
var dataEntries: [BarChartDataEntry] = []
for i in 0..<dataPoints.count {
let value = values[i] as Double
print("value=\(value)")
let dataEntry = BarChartDataEntry(x: Double(i), y:value)
dataEntries.append(dataEntry)
}
let chartDataSet = BarChartDataSet(values: dataEntries, label: "Total Amount")
chartDataSet.colors = [.red, .yellow, .green, .blue, .brown]
chartDataSet.colors = ChartColorTemplates.joyful()
barChartView.xAxis.labelPosition = .bottom
barChartView.chartDescription?.text = ""
barChartView.xAxis.drawGridLinesEnabled = false
barChartView.leftAxis.drawLabelsEnabled = false
barChartView.leftAxis.granularityEnabled = true
let chartData = BarChartData()
chartData.addDataSet(chartDataSet)
barChartView.data = chartData
Run Code Online (Sandbox Code Playgroud) 我正在将fitbit集成到我的应用程序中,我不希望用户每次都重定向到SafariViewController以获取访问令牌,因为我存储了访问令牌,但24小时后访问令牌即将到期.
在fitbit Fitbit OAuth 2.0的API中,有一个参数expires_in用于定义访问令牌的到期时间.在该参数中,我传递31536000了1年,但之后,访问令牌也在24小时内到期,之后我必须将用户重定向到SafariViewController.
那么,是否有任何解决方法,以便我不必将用户重定向到SafariViewController,我将通过它在后台刷新令牌的任何方法,类似的东西.
任何帮助,将不胜感激.
干杯!!!!!
ios ×6
objective-c ×4
swift ×2
arrays ×1
charts ×1
decimal ×1
dictionary ×1
fitbit ×1
oauth-2.0 ×1
sdwebimage ×1
yaxis ×1