Could not cast value of type ‘UICollectionViewCell’

The template for a CollectionViewController in Xcode comes with this line of code in viewDidLoad, which changes the specification in your storyboard. // Register cell classes self.collectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) Simply delete that line. In older Swift versions the line is: // Register cell classes self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)

How can I get the content of CKEditor using JQuery?

use the CKEditor.editor.getData() call on the instance. That is to say: HTML <textarea id=”my-editor”> <input id=”send” type=”button” value=”Send”> JS for CKEditor 4.0.x $(‘#send’).click(function() { var value = CKEDITOR.instances[‘DOM-ID-HERE’].getData() // send your ajax request with value // profit! }); JS for CKEditor 3.6.x var editor = CKEDITOR.editor.replace(‘my-editor’); $(‘#send’).click(function() { var value = editor.getData(); // send your …

Read more

Scroll smoothly to specific element on page

Question was asked 5 years ago and I was dealing with smooth scroll and felt giving a simple solution is worth it to those who are looking for. All the answers are good but here you go a simple one. function smoothScroll(){ document.querySelector(‘.your_class or #id here’).scrollIntoView({ behavior: ‘smooth’ }); } just call the smoothScroll function …

Read more

android.support.v4.content.FileProvider not found

As of AndroidX (the repackaged Android Support Library), the path is androidx.core.content.FileProvider so the updated provider tag would be: <provider android:name=”androidx.core.content.FileProvider” android:authorities=”${applicationId}.fileprovider” android:exported=”false” android:grantUriPermissions=”true”> <meta-data android:name=”android.support.FILE_PROVIDER_PATHS” android:resource=”@xml/file_paths” /> </provider> Android Support Libraries are now in the androidx.* package hierarchy. android.* is now reserved to the built-in Android System Libraries.

How to create a random string using PHP?

If you want to allow repetitive occurences of characters, you can use this function: function randString($length, $charset=”ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789″) { $str=””; $count = strlen($charset); while ($length–) { $str .= $charset[mt_rand(0, $count-1)]; } return $str; } The basic algorithm is to generate <length> times a random number between 0 and <number of characters> − 1 we use as …

Read more

Keyboard events in a WPF MVVM application?

To bring an updated answer, the .net 4.0 framework enables you to do this nicely by letting you bind a KeyBinding Command to a command in a viewmodel. So… If you wanted to listen for the Enter key, you’d do something like this: <TextBox AcceptsReturn=”False”> <TextBox.InputBindings> <KeyBinding Key=”Enter” Command=”{Binding SearchCommand}” CommandParameter=”{Binding Path=Text, RelativeSource={RelativeSource AncestorType={x:Type TextBox}}}” …

Read more