小编Eli*_*Eli的帖子

UITextField和UISearch Bar禁用大写字母按钮-Swift

我在社交网络上工作,我希望用户名只能小写,在用户名文本字段中我如何使键盘不允许使用大写字母(事实发生后,我可以强制将textfield.text字母转换为小写,但我不这样做我真的还需要它来用于UISearchBox,因为如果小写用户可以激活大写字母按钮,则搜索小写用户将无法正常工作(在搜索中返回nil)

uitextfield uisearchbar swift

2
推荐指数
1
解决办法
2461
查看次数

如何在每天的特定时间发送localNotification,即使该时间已经过去了?

我有这个代码每天早上7点运行一个通知,它获取当前日期,然后当它达到设定的小时时运行通知,我的问题是如果时间已经超过设定的运行时间,那么每天它将运行在用户当前时间不是我早上7点的时间,这是我的代码

var dateFire: NSDateComponents = NSDateComponents()
var getCurrentYear = dateFire.year
var getCurrentMonth = dateFire.month
var getCurrentDay = dateFire.day

dateFire.year = getCurrentYear
dateFire.month = getCurrentMonth
dateFire.day = getCurrentDay
dateFire.hour = 7
dateFire.minute = 0
dateFire.timeZone = NSTimeZone.defaultTimeZone()


var calender: NSCalendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
var date: NSDate = calender.dateFromComponents(dateFire)!

var localNotification = UILocalNotification()
localNotification.fireDate = date
localNotification.alertBody = "A new day has begun and a fresh layer on snow lies on the mountain! Can you beat your highscore?"
localNotification.repeatInterval = NSCalendarUnit.CalendarUnitDay

UIApplication.sharedApplication().scheduleLocalNotification(localNotification) …
Run Code Online (Sandbox Code Playgroud)

nsdate ios localnotification swift

1
推荐指数
2
解决办法
6916
查看次数

Firebase 2.0 - 从FIRDataSnapshot读取数据不起作用

我有一个搜索栏,当你键入它时,在数据库中搜索该用户的用户名.找到用户名的代码可以工作,但是当我尝试读取特定值时,它会崩溃.这是代码

func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {

          Database.child("users").queryOrderedByChild("username").queryEqualToValue(searchText).observeSingleEventOfType(.Value, withBlock: { snapshot in

        print(snapshot)
        print(snapshot.value!["first_name"] as? String)
        print(snapshot.value!["last_name"] as? String)
        print(snapshot.value!["username"] as? String)
        print(snapshot.value!["profile_picture_url"] as? String)
    })
}
Run Code Online (Sandbox Code Playgroud)

打印快照的结果是

Snap (users) {
12345UIDEXample =     {
    "first_name" = Bob;
    "last_name" = Someone;
    "profile_picture_url" = "exampleurl.com";
    username = bobby;
  };
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试访问时

snapshot.value!["first_name"] as? String
Run Code Online (Sandbox Code Playgroud)

它会返回nil并崩溃?为什么如果它在json中清楚地显示它返回的数据是那里但不会让我抽出值?

firebase swift firebase-realtime-database

1
推荐指数
1
解决办法
1545
查看次数

Firebase 检索数据并作为类型数组返回 - 我的解决方案

我最近开始将我的 iOS 应用程序也转变为网络应用程序。我不知道这个实现是否正确。它有效,但如果有人可以请告诉我它是否正确。

这是我的 LicenseService 中的函数:

get retriveLicences():Licence[] {

const licences: Licence[] = [];

this.afDatabase.list(this.basePath).valueChanges().subscribe((snapshot) => {
  snapshot.forEach(element => {

    const licenceObject = <any>element

    licences.push(
      new Licence(
        licenceObject.name, 
        licenceObject.logoUrl, 
        licenceObject.maxUsers, 
        licenceObject.currentUserCount, 
        licenceObject.startDate, 
        licenceObject.endDate
      )
    );
  });
});

return licences
}
Run Code Online (Sandbox Code Playgroud)

typescript angularfire firebase-realtime-database angularfire2 angular

1
推荐指数
1
解决办法
1310
查看次数