setTranslatesAutoresizingMaskIntoConstraints - uibutton

I'm trying to create a custom keyboard for iOS 10 and in my code I have
let button = UIButton(type: .system)
button.setTranslatesAutoresizingMaskIntoConstraints(false)
...
but I get the error
Value of type 'UIButton' has no member 'setTranslatesAutoresizingMaskIntoConstraints'
Scouring online forums I can't find any explanation of what happened to this method between Swift 2 and Swift 3.
I can't find any mention of it in the official docs
Was it deprecated? Was it renamed?
I'm using Xcode Version 8.2.1 (8C1002)

The answer as user Fogmeister pointed out is that in swift 3 setTranslatesAutoresizingMaskIntoConstraints is now a property again and not a method as it was in swift 2.
let button = UIButton(type: .system)
button.setTranslatesAutoresizingMaskIntoConstraints = false

Related

Apple Watch app AVSpeechSynthesizer not working in background

In my watchkit extension capability section there is no option to check the checkbox for audio in background mode section.
I have also checked apple doc .
They are only 3 exception.
1) NSURLSession
2) WKAudioFilePlayer or WKAudioFileQueuePlayer
3) HKWorkoutSession
But i need my dynamic text to speak by the system.
I am using this code
let dictSetting = UserDefaults.standard.value(forKey: "settings") as! [String : String]
let settingObj = SettingWatch(fromDict: dictSetting)
let utterance = AVSpeechUtterance(string: text)
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
self.synth = AVSpeechSynthesizer()
self.synth?.delegate = self
self.synth?.speak(utterance)
Is there any way that i can my Apple Watch app can speak the text even if in backgound. Or is there any way to keep my app in foreground?
Please suggest if you have came across any solution.

iOS Navigation Bar Prefers Large Titles Scroll Behaviour

In iOS 11 the system apps all compress the navigation bar as you scroll down if you enable prefersLargeTitles:
I can't figure out how to implement this in my own apps though, the bar stays the same by default:
The only thing I can see is Hide Bars On Swipe, but that hides the whole bar rather than compressing it:
This is just an empty project created in Xcode 9 beta and with a new storyboard added.
What do I need to do to get the same behaviour as the system apps?
Don't set anything regarding Large Titles in Interface Builder / Storyboard, only in code. That worked for me.
So in the navigation bar in storyboards, Prefers Large Titles unchecked.
In your view controller:
self.navigationController?.navigationBar.prefersLargeTitles = true
It seems like this issue is happening to people for different reasons. None of the above answers helped me, but here's what DID work...
I deconstructed my app to find the cause, which was the view hierarchy in the storyboard. It appears that the UITableView view HAS to the the first view in your view controller. I had a UITableView with two UIImageViews behind it and that's what was causing the issue. Once I removed those UIImageViews everything worked correctly.
My fix: I ended up creating a UIView in code, adding my two image views to that, THEN adding that UIView to the UITableview.backgroundView.
Hope this helps someone.
If you have to target older iOS versions, you’ll also have to wrap the assignment in an availability check:
if #available(iOS 11, *) {
self.navigationController?.navigationBar.prefersLargeTitles = true
}
if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitles = true
navigationController?.navigationBar.topItem?.title = "Hello"
navigationController?.navigationItem.largeTitleDisplayMode = .automatic
let attributes = [
NSAttributedStringKey.foregroundColor : UIColor.red,
]
navigationController?.navigationBar.largeTitleTextAttributes = attributes
} else {
// Fallback on earlier versions
}
http://iosrevisited.blogspot.in/2017/09/navigation-bar-with-large-titles-and.html

Xamarin.Forms - Looking for a Popover

I'm working in a Xamarin.Forms project (iOS & Android) that needs something similar to the Bootstrap Popover. I didn't find something similar in the docs.
Q:
Does anyone know a Nuget Package or something similar that in order to include that UI component to a Xamarin.Forms project?
PS: Yes, I tried searching in Google and I could not found a solution.
I think Rg.Popup is a good solution...
// Use these methods in PopupNavigation globally or Navigation in your pages
// Open new PopupPage
Task PushAsync(PopupPage page, bool animate = true) // Navigation.PushPopupAsync
// Hide last PopupPage
Task PopAsync(bool animate = true) // Navigation.PopPopupAsync
// Hide all PopupPage with animations
Task PopAllAsync(bool animate = true) // Navigation.PopAllPopupAsync
// Remove one popup page in stack
Task RemovePageAsync(PopupPage page, bool animate = true) // Navigation.RemovePopupPageAsync
Try out CPOP. It's a popup plugin for Xamarin.Forms (iOS, Android, UWP). It's not the prettiest of the popups, but you can modify the colors. (Also, I think this is the only popup plugin available out there)
NuGet Package: https://www.nuget.org/packages/Calvagna.CPop/
Hope it helps!
I'd try SlideOverKit, it might do more than you need, but it has a nice range of ways of doing popover type things.

How do I dynamically change the height of a TableViewRow?

Application Type: mobile
Titanium SDK: 3.1.0.GA
Platform & version: iOS 6.1
Device: iOS Simulator
Host Operating System: OSX 10.8.3
Titanium Studio: 3.1.0.201304151600
I'd like to conditionally show/hide a textfield in a TableViewRow. In order to do this I need to expand the height of the row. The following code doesn't work, though. The TableViewRow is actually an Alloy controller. I first tried animating it before I realized that it can't be animated. Now I'm just trying to change the height and that isn't even working. I've tried using the setHeight method along with just setting the height property directly to no avail.
Any ideas?
var notesVisible = false;
function notes_click() {
if(notesVisible == false) {
Ti.API.info('expanding');
$.row.height = 200;
// $.notes_container.setHeight(124);
notesVisible = true;
} else {
Ti.API.info('contracting');
$.row.height = 75;
$.notes_container.setHeight(0);
notesVisible = false;
}
};
There are two good ways of doing this, both should be done from the click event listener.
Method 1) One way is to directly change the "height" variable of the row
Method 2) The second is to create a new row and replace the current row with the new row
Method 1 is more straightforward but I found it to be glitchy depending on what version of the SDK you are using, but with 3.1.0 it should work. Both methods should be called from the 'click' eventListener as its easier to tell Titanium which row to act on based on the click
So here is an example
currentTableview.addEventListener('click',function(e)
{
// DO whatever your row is supposed to do when clicked
// Now lets change the height of the row to a new height, 200 in this example
e.row.height = 200
}
With Method two, it involves creating a new row and then replacing the current row with this call
currentTableview.updateRow(e.index,newlyCreatedUpdatedRow);
I know its an old question asked by some one but the solution provided will not work and i think best solution for this is by making a recursive function and changes the height of your row and need to play with the visibility of views inside that row hopefully will help someone :)

keyboard movement when we click on textfield in obj c

hii every one,
In my iphone app i need to scroll the page on click of textfield,actually it was working fine with xcode 3 ,on ios device 3.1.3,when i was using "UIKeyboardBoundsUserInfoKey"
but when i upgraded my xcode 3 to 4,it gave a warning saying that UIKeyboardBoundsUserInfoKey is deprecated u cant use ,so i replaced that API by UIKeyboardFrameBeginUserInfoKey now warning is gone but its not working on ios device 3.1.3,when i click on textfield it ill try to scroll the page but it ill crash,,how can i fix this,,can any one help me,...... thanx in advance
try this:
if (&UIKeyboardFrameBeginUserInfoKey!=nil) {
// use UIKeyboardFrameBeginUserInfoKey
} else {
// use UIKeyboardBoundsUserInfoKey
}