当我添加通知时:
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.plus)
.setContentTitle(title)
.setAutoCancel(true)
.setContentText(text)
.setSound(RingtoneManager .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setLargeIcon(bm);
Run Code Online (Sandbox Code Playgroud)
我看到大图标和小图标: 
如何只设置大图标,不小.如果只使用setLargeIcon,我根本看不到通知,只是声音警报.
如何更改标签栏未选择的图标和文字的颜色?我找到了这个答案(如何更改标签栏上的非活动图标/文本颜色?),但无法为swift实现它.
我想改变不同状态的按钮背景.我试试这样:
@IBAction func addToShedulerAction(sender: UIButton) {
println(sender.backgroundColor)
if sender.backgroundColor==UIColor.redColor(){
sender.backgroundColor==UIColor.whiteColor()
}
else //if sender.backgroundColor==UIColor.whiteColor()
{
sender.backgroundColor=UIColor.redColor()
}
}
Run Code Online (Sandbox Code Playgroud)
但在第一个按钮println打印nil和背景变为红色,在第二次打印println打印"可选(UIDeviceRGBColorSpace 1 0 0 1)"和颜色不会改变
我的UITableView中的某些行需要删除并在编辑模式下移动,但有些行只是移动.在这种方法中,我可以启用或禁用某些行的编辑
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool{
return true
}
Run Code Online (Sandbox Code Playgroud)
但是如何在启用移动的情况下禁用某些行的删除?
我通过故事板为UIView设置了背景颜色,但我在模拟器中看到了更亮的颜色.它与Button图像背景不同,代码相同,草图使用相同的代码.阿尔法设置1.什么可能是错的?
对于Android 4.3及更早版本,我使用这个方法:
Uri myUri = data.getData();
Cursor cursor = getContentResolver().query(myUri,new String []{"_data"}, null, null, null);
cursor.moveToFirst();
String filePath = cursor.getString(cursor.getColumnIndex("_data"));
cursor.close();
Run Code Online (Sandbox Code Playgroud)
但对于Android kitKat,它返回null
我找到了针对objective-c的解决方案:在常规UIViewController上的UITableViewCell中将键盘上方的UITextField滚动,但我无法将其改编为swift.
func textViewShouldBeginEditing(textView: UITextView) -> Bool {
var pointInTable:CGPoint? = textView.superview?.convertPoint(textView.frame.origin, toView: tableView)
var contentOffset:CGPoint = tableView.contentOffset
contentOffset.y = pointInTable?.y - textView.inputAccessoryView?.frame.size.height
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:
Value of optional type 'CGFloat?' not unwrapped; did you mean to use '!' or '?'?
Run Code Online (Sandbox Code Playgroud)
我用的时候!要么 ?我收到错误:postfix的操作数'?' 应该有可选的类型; 类型是'CGFloat'
我找到了NSXMLParser构造函数使用URL的示例,例如:
NSXMLParser(contentsOfURL: (NSURL(string:"http://images.apple.com/main/rss/hotnews/hotnews.rss")))!
Run Code Online (Sandbox Code Playgroud)
但是我找不到如何将它与项目中的xml文件一起使用.