我在UITableViewCell中有一个操作按钮,我想检测按钮的按下时间以及ViewController中按下的单元格编号,以便在ViewController.swift中创建音频播放列表.
我已经陷入这个问题一段时间了,我真的很赞赏你的建议.这是代码.
ViewController.swift
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.register(UINib(nibName: "Cell", bundle: nil), forCellReuseIdentifier: "cell")
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! Cell
return cell
}
}
Run Code Online (Sandbox Code Playgroud)
Cell.swift
import UIKit
class Cell: UITableViewCell {
@IBOutlet weak var button: UIButton! …Run Code Online (Sandbox Code Playgroud) 我正在开发一个iOS应用程序,现在我遇到了Firebase部署功能.我正在尝试发送推送通知,我准备了如下代码.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.pushNotifications = functions.database.ref('/messages/{messageId}')
.onCreate(event => {
const data = event.data;
const fromId = data.fromId;
const toId = data.toId;
const message = data.message;
console.log(fromId + ' sent a message to' + toId);
return admin.database().ref('/users/' + fromId).once('value', snapshot => {
var user = snapshot.val();
var payload = {
notification: {
title: user.username,
body: message
}
}
admin.messaging().sendToDevice(user.fcmToken, payload)
.then(function(response) {
// See the MessagingDevicesResponse reference documentation for
// the contents of response. …Run Code Online (Sandbox Code Playgroud) javascript node.js firebase firebase-realtime-database google-cloud-functions
我正在编写一个没有故事板的Swift iOS应用程序.
我可以在模拟器和我的物理设备上运行应用程序但是当我尝试将项目文件上传到App Store时,下面的消息显示出来,我不知道该怎么做.
启动故事板未找到.确保为Info.plist中的密钥UILaunchStoryboardName指定没有文件扩展名的启动故事板文件名.
在这种情况下有人知道该怎么做吗?
我正在尝试以编程方式自定义UISearchBar设计。我尝试添加一堆代码,但仅更改了一些地方。
这是我要创建的设计。
这就是现在的样子。
我从模拟器截屏了第二张图像,所以它更大了。
无论如何,我正在尝试使我的搜索栏具有
这是我的代码:
let searchBar = UISearchBar(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 60))
[In viewDidLoad()]
searchBar.delegate = self
searchBar.isTranslucent = false
searchBar.placeholder = "Search the phrase"
searchBar.tintColor = UIColor(red:0.73, green:0.76, blue:0.78, alpha:1.0)
searchBar.setImage(UIImage(named: "search"), for: .search, state: .normal)
let forTextField = searchBar.value(forKey: "searchField") as? UITextField
forTextField?.textColor = UIColor(red:0.31, green:0.31, blue:0.31, alpha:1.0)
forTextField?.font = UIFont(name: "HelveticaNeue-Light", size: 14)
forTextField?.clipsToBounds = true
forTextField?.layer.cornerRadius = 5
forTextField?.frame.size.height = 30
Run Code Online (Sandbox Code Playgroud)
多谢您的协助!