小编Ale*_*ehr的帖子

Swift:单击UICollectionView的单元格并打开AlertViewController

在我的应用程序中,我使用的是UICollectionView.现在我想在点击集合视图的任何单元格时开发一个UIAlertController.我开始使用以下代码:

extension HomeViewController: UICollectionViewDataSource {

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    …
}

// specify cells
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    ….
}

// called when widget is moved
func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
        …
}

// called when clicked
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
    print("Got clicked!")
}

}
Run Code Online (Sandbox Code Playgroud)

但不知何故,"点击了!" 永远不会打印.

click ios uicollectionview swift

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

将图像上传到Google云端存储(Java)

我想开发一个java应用程序(用于PC),可以将任何图片上传到Google云端存储.虽然我整个晚上都在寻找解决方案,但我没有任何线索如何开始.您是否有人将图像上传到Google云端存储?谷歌云存储有更好的替代方案吗?

java cloud google-app-engine google-cloud-storage

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

Java - 同步块的工作方式与方法不同

我想弄清楚,同步块和同步函数之间的区别实际上是什么.本规范运作完美,因为它避免了关键部分的错误

class ThreadSynchronous extends Thread {
static int m_count = 0;
String s;

ThreadSynchronous(String s) {
    this.s = s;
}

public void run() {
    synchronized (getClass()) {
        ...
    }
}
}

public class ThreadExample {
public static void main(String[] args) {
    Thread t1 = new ThreadSynchronous("Thread1: ");
    Thread t2 = new ThreadSynchronous("Thread2: ");
    t1.start();
    t2.start();

    try{
        t1.join();
        t2.join();
    } catch (InterruptedException e){
    }
}
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我使用public synchronized void run()它,它不会同等/正确地工作.

java critical-section

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