swift3

Add a button on right view of UItextfield in such way that, text should not overlap the button

蓝咒 提交于 2020-01-11 15:37:00
问题 I can add a button to a textfield on the right hand side of the UITextField using the right view however, the text overlaps on the button. Below is the code for right view button UIView.commitAnimations() var btnColor = UIButton(type: .Custom) btnColor.addTarget(self, action: #selector(self.openEmoji), forControlEvents: .TouchUpInside) btnColor.frame = CGRect(x: CGFloat(textField.frame.size.width - 25), y: CGFloat(5), width: CGFloat(25), height: CGFloat(25)) btnColor.setBackgroundImage

Use unresolved identifier

瘦欲@ 提交于 2020-01-11 14:49:51
问题 My app was working fine and now suddenly Xcode is giving me this error: use unresolved identifier cardWasRemoved func addNewCards() { countOfCards = countOfCards-1 if(countOfCards >= 0){ self.arrayAuthorization.remove(at: dm.objectIndexToRemove) cardWasRemoved(removeIndex: dm.objectIndexToRemove) } } And my method implementation is this: open func cardWasRemoved(removeIndex:Int) { if layout.newCardShouldAppearOnTheBottom { layout.cardDidRemoved(removeIndex) } else { layout.cardDidRemoved

Value of variable not changing in observeSingleEvent

瘦欲@ 提交于 2020-01-11 13:40:13
问题 The variable num changes to what I want inside the observeSingleEvent, but just after it changes back to an empty value. How do i get the value of num to change?? var num = Int() FIRDatabase.database().reference().child("menus/Day1").observeSingleEvent(of: .value, with: {(snap) in print(snap) if let snapDict = snap.value as? [String:AnyObject]{ self.num = snapDict["date"] as! Int print(num) //returns the number I want } }) print(num) //Returns an empty value if num == 5 { print("number is 5")

how to use persian numbers in UItextField in swift 3?

心已入冬 提交于 2020-01-11 13:16:55
问题 Hi I am using text field in my swift3 application - I want when user enter a number in the text field instead of english number textfield shows persian numbers - my textfield keyboard has set to just enter number so the user can't use text inside the text field with keyboard so here is my codes that doesn't work override func viewDidLoad() { super.viewDidLoad() let numberFormatter = NumberFormatter() numberFormatter.locale = Locale(identifier: "fa") numberFormatter.numberStyle =

how to use persian numbers in UItextField in swift 3?

▼魔方 西西 提交于 2020-01-11 13:16:06
问题 Hi I am using text field in my swift3 application - I want when user enter a number in the text field instead of english number textfield shows persian numbers - my textfield keyboard has set to just enter number so the user can't use text inside the text field with keyboard so here is my codes that doesn't work override func viewDidLoad() { super.viewDidLoad() let numberFormatter = NumberFormatter() numberFormatter.locale = Locale(identifier: "fa") numberFormatter.numberStyle =

Swift 3 - Why is my Navigation Bar not showing?

二次信任 提交于 2020-01-11 12:09:28
问题 I have a simple app to test push notifications of a rest api. I would like to show the Navigation Bars in the App but it is not working. In my AppDelegate I have the following code: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { self.registerForPushNotifications() let url = "dev" UserDefaults.standard.setValue(FFHelper.url(slug: url.slug()), forKey: "api-url") var vcString = "loginView" if

How to change UIWebView orientation programmatically in Swift

笑着哭i 提交于 2020-01-11 11:48:31
问题 I've created UIWebView programmatically. Now i want to set programmatically its orientation to (landscape or portrait). Please can anyone tell me how i can do this? Thanks import UIKit class ViewController: UIViewController, UIWebViewDelegate { override func viewDidLoad() { super.viewDidLoad() let webV:UIWebView = UIWebView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height)) webV.loadRequest(NSURLRequest(URL: NSURL(string: "http://tune.tv/humtv

Swift 3 : Error: Type 'Any' has no subscript member

岁酱吖の 提交于 2020-01-11 11:48:08
问题 I updated to Swift 3 and I get this error and I can't solve it. Type 'Any' has no subscript member I already read the answers: 39480150 - 38956785 - 39516199 But I couldn't solve my problem with the answers. This is my code: let pathperdataselezionata = Bundle.main.path(forResource: "Annuale", ofType: "plist") let dictperdataselezionata = NSDictionary(contentsOfFile: pathperdataselezionata!) as![String:AnyObject] let valoridataodierna = dictperdataselezionata[annoscelto]?[mesescritto]?!

Merge arrays with condition

末鹿安然 提交于 2020-01-11 09:46:13
问题 I would like to merge two arrays with specific condition and update objects that they are containing. First my struct that is in arrays: struct Item { var id:Int var name:String var value:Int } Second elements for the two arrays: let fisrt = Item(id: 1, name: "Oleg", value: 3) let second = Item(id: 2, name: "Olexander", value:5) let fisrtInSecond = Item(id: 1, name: "Bogdan", value: 6) let secondInSecond = Item(id: 2, name: "Max", value: 9) Arrays: var fisrtArray = [fisrt, second] let

Xcode8 cannot connect multiple/single uibuttons to single @IBAction in swift file

让人想犯罪 __ 提交于 2020-01-10 22:30:16
问题 I am using Xcode 8 beta. I cannot drag multiple UIButtons from storyboard to connect to a single @IBAction in swift file. Bug? Thanks for your help. 回答1: By Using this workaround you can add existing action and also can connect multiple buttons to a single action. I think there is a bug in Xcode8. You can add multiple/Single button to a single action /function by changing sender to _ sender eg :- Normal Button @IBAction func huu(sender: UIButton) { } You can't add multiple buttons or single