UIButton not appearing in Rubymotion - rubymotion

For some reason my UIButtons aren't appearing in my ruby motion apps. Only the button text appears.
Here's the code:
#containerView = UIView.alloc.initWithFrame([[0, 50], [self.view.frame.size.width, 100]])
#loginButton = UIButton.buttonWithType(UIButtonTypeRoundedRect)
#loginButton.frame = [[(self.view.frame.size.width / 2) + 5, 65], [(self.view.frame.size.width / 2) - 15, 40]]
#loginButton.setTitle('Login', forState: UIControlStateNormal)
#loginButton.addTarget(self,
action:'login',
forControlEvents:UIControlEventTouchUpInside)
#containerView.addSubview(#loginButton)
self.view.addSubview(#containerView)
I'm using RubyMotion v2.16, Promotion 1.0.4, sugarcube 1.3.5, motion layout 0.0.1 and bubblewrap 1.4.0
I've tried to render the buttons using the promotion way, the sugarcube way and the bubblewrap way but decided to break it down to the raw rubymotion way (above) for troubleshooting in a regular view controller. Any ideas on this one?

Well, if anyone else is reading outdated documentation also, it turns out that UIButtonTypeRoundedRect has been deprecated in iOS7.
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TransitionGuide/Controls.html#//apple_ref/doc/uid/TP40013174-CH9-SW1

Related

Python | Tkinter | TkCalendar : how to customize 'DateEntry Date Picker' object? like increasing Width, and more?

I'm developing a simple Python stand-alone application, that uses a GUI datePicker, and I went for using 'from tkcalendar import DateEntry'. | using python 2.7 (for older windows PC)
while using 'DateEntry - Date Picker', I not able to find a few major things, even the documentation doesn't explain on this. I went through these:
https://tkcalendar.readthedocs.io/en/stable/DateEntry.html#
https://tkdocs.com/shipman/
https://www.plus2net.com/python/tkinter-DateEntry.php
I'm looking ways to
Change width of Widget
open widget on click of entry/input bar (not only drop-down arrow)
Code Ex:
DateEntry(window, date_pattern='yyyy-MM-dd', width= 67, background=CONST.TITLE_BG_COLOR, bad=2)
Any suggestion, references and even alternative are appreciated. Thanks.

Add button in SwiftUI Stepper not hittable during XCTest

My stepper is defined as follows (Standalone WatchOS app)
Stepper(value: $myCount) {
Text("\(myCount)").font(.footnote).accessibilityIdentifier("count_label")
}.accessibilityIdentifier("my_stepper")
It is fully functional on the real / simulator devices. During a test case, defined below, I am unable to invoke the increment button. (I get an error and the button itself is not hittable, ever)
XCTAssertTrue(app.steppers["my_stepper"].waitForExistence(timeout: 10))
XCTAssertFalse(app.steppers["my_stepper"].buttons["Remove"].isEnabled)
XCTAssertTrue(app.steppers["my_stepper"].buttons["Add"].isEnabled)
-> (Error) app.steppers["my_stepper"].buttons["Add"].tap()
Error kAXErrorCannotComplete performing AXAction
kAXScrollToVisibleAction on element AX element pid
I tried to forceTap (using coordinates) with no luck. Any idea how to invoke the increment action?
While the increment and decrement buttons exist in the view stack, they are not hittable. Likely a bug in SwiftUI that impacts either WatchOS or all platforms. Best way I have found to temporarily get past the issue is using the following tutorial :
app.steppers["my_stepper"].coordinate(withNormalizedOffset: CGVector(dx: 0.9, dy: 0.5)).tap()
This is a workaround that will probably fail on different devices. For me, it would only work with Ultra 49mm watchOS 9.0. Accepting this until a better answer is found.

SwiftUI fails to build preview with compiling error

When I go to view my SwiftUI through the canvas preview in Xcode 11.3.1 I am getting the error
Compiling failed: 'Color' is only available in iOS 13.0 or newer
But the project itself builds successfully and the simulator loads without any issues. I have tried clearing the build folder, quitting Xcode and rebuilding but still no luck.
Any help would be great. Thanks in advance.
SwiftUI minimum deployment target is 13.0, so if you have project with support of older version, then all SwiftUI code (including preview providers) you have to prepend with availability modifier, like
#available(iOS 13.0, *) // << here !!
struct Demo: View {
var body: some View {
VStack {
Text("Hello")
}
}
}
You Should use Assets or Other option like Color Literal for Color.
Don't use the system Color option since your deployment target is 11.4.
Man, I've had a similar issue. The problem was that sometimes my preview worked sometimes it didn't... I reviewed the diagnostics and realized that there are some #_dynamicReplacement attributes mentioned (which are used, I guess, for hot reloading). It wasn't working when I've had a file with #available attributes opened in the (adjacent) editor. When I closed that editor everything worked back again.
Magic ✨
Also one more hint from my friend - when you have a file from another target (not the one hosting your Canvas-related code) in (adjacent) editor it behaves the same way.

Crash during UICollectionViewCell reordering after Swift 3.0 migration

I do have a strange issue in using the reorder feature in my app's UICollectionView. We have a custom layout which is implemented to show a decoration view. The collection view uses a flow based layout. When I move the first cell from its position to last cell position for reordering of the cells, the app crashes before it calls the collection view delegate's collectionView(moveItemAt: to) method.
Attached the stack trace of this issue. You can see that crash is happening in the bridging between NSIndexPath and IndexPath. I am not sure why it is happening inside UIKit. Searching for this issue found that it appears to be bug inside UIKIt which got introduced in Swift 3.0. I tested my old build which was built before swift 3.0 migration and it works without any crashes.
Can someone tell me how can I fix this issue?
Related bugs links
UICollectionView broken after Swift 3 migration?
https://bugs.swift.org/browse/SR-2103
https://bugs.swift.org/browse/SR-2417
func handleLongGesture(_ gesture: UILongPressGestureRecognizer) {
switch(gesture.state) {
case UIGestureRecognizerState.began:
if let movingPageIndexPath = collectionView.indexPathForItem(at: gesture.location(in: collectionView)) {
collectionView.beginInteractiveMovementForItem(at: movingPageIndexPath)
}
case UIGestureRecognizerState.changed:
collectionView.updateInteractiveMovementTargetPosition(gesture.location(in: collectionView))
case UIGestureRecognizerState.ended:
collectionView.endInteractiveMovement()
default:
collectionView.cancelInteractiveMovement()
}
}

Cocos2d-Swift v3.x Sprite Builder : In iPad iPhone sd images are used. -ipad suffix ignored

Code:
var bg = CCSprite(imageNamed:"Background.png")
Images used in Resource:
Background-hd.png
Background-ipad.png
Background-ipadhd.png
Background-iphone5hd.png
Background.png
In all device Background.png(320x480) used, other images are ignored. How to fix this ?
Retina display is not enabled...How to enable retina display in v3 ?
Here is working sample code with this problem.
I'm not really advanced user of SpriteBuilder but have some concerns about your issue.
As you are using Sprite Builder for starting the project, it configures your CCFileUtils to distinguish different devices' resources by looking at folders, not prefixes. In your app delegate you can see this line:
[CCBReader configureCCFileUtils];
going into this method you can see that search mode for file utils is set to CCFileUtilsSearchModeDirectory
sharedFileUtils.searchMode = CCFileUtilsSearchModeDirectory;
So you need to use Publish folders and copy your Background image to each of them with the same name (Background.png), but with different resolution for each device.
You don't need to use image suffixes in SpriteBuilder at all.
Finally Updated Cocos2d and now -hd,-ipad files are used. Just updated one line
sharedFileUtils.searchMode = CCFileUtilsSearchModeSuffix