Posts

Showing posts from January, 2020

shortcuts for concatenating strings iOS

Solution: 1. NSMutableString is one option for concatination strings.It containg appendingstring function. 2. Another option is NSArray.It contains  componentsJoinedByString function for appending.

draw an image based on one image iOS Objective c

Solution: The below function is used for draw an image with reference image inside one rect. Call the function using below code. Call : [self draw]; Function : -(void) draw {          CGContextRef cont = UIGraphicsGetCurrentContext();          UIImage *_originalImg = [UIImage imageNamed: @ "drawing_img" ];     [_originalImg drawInRect:CGRectMake( 0 .f, 0 .f, _originalImg.size.width, _originalImg.size.height)];          }

Set text Inset for UITextField in iOS swift

Solution: If you want the textfield text to be like one space after the initial position of textfield from the left side then do the following. Objective c:         // placeholder inset         - ( CGRect ) t extRectForBounds:(CGRect)bounds {     return CGRectInset(bounds, 10 , 10 );     }          // text inset     - (CGRect)editingRectForBounds:(CGRect)bounds {     return CGRectInset(bounds, 10 , 10 );      } Swift :     let inset: CGFloat = 8          // placeholder position     override func textRect(forBounds bounds: CGRect ) -> CGRect {         return bounds.insetBy(dx: inset, dy: inset)     } must be use uitextfield delegate.

Navigate through next button in textFields iOS swift

Problem: I want to navigate to next field that wants to be focusable when i click next button.If i click the end textfield then keyboard wants to be hidden. Solution: In textfield delegate method do the following. Objective c:     - (BOOL)textFieldShouldReturn:(UITextField*)textField     {     NSInteger nextTF = textField.tag + 1 ;     UIResponder* nextResponder = [textField.superview viewWithTag:nextTF];     if (nextResponder) {     [nextResponder becomeFirstResponder];     } else {     [textField resignFirstResponder];     }     return NO;          } Swift:     func textFieldShouldReturn( _ textField: UITextField ) -> Bool {         let myTextField = textField. tag + 1         let nextResponder = textField. superview ?. viewWithTag (myText...

How to click a button behind transparent UIView iOS swift?

Solution: First disable the userinteraction to the view.Then you can easily click the button behind the UIView. behindView.userInteractionEnabled = NO;

Safely delete the derived data contents in XCode

Image
Solution: 1.Open Xcode select on top menu Xcode -> Preference It will open one window In that select location as like above in sub menu it will show you two options. 1. Locations 2. Custom paths. In that select locations. In below it will show you derived data Click on the arrow that has been shown as above.It will open one finder and show you the all app derived data. You can select whatever app or all apps then delete it to clear the data.

Xcode keyboard does not show up in simulator

Image
Problem: When run the app in simulator and tap the textView or textField keyboard not shows. Solution: 1. Goto iOS simulator -> select menu hardware -> select keyboard -> Toggle software keyboard. 3.Uncheck connect Hardware keyboard.

How to hide unwanted strange logs iOS

Image
Solution: 1. Goto Xcode menu Product -> scheme -> Edit scheme 2. In left menu select Run -> in menu select arguments  3.On environment variable OS_ACTIVITY_MODE = disable. 4. After that logs will be disabled.

Eliminate extra seperators in UITableView iOS swift || Remove the seperators in tableView iOS

Solution: You can set the view to tableView footer view to eleminate the extra seperators appear in the tableView. Use the below code Swift:     override func viewDidLoad() {         super . viewDidLoad ()         self .tableView.tableFooterView = UIView() } Objective C:         self .tableView.tableFooterView = [UIView new];

XCode process launch failed security

Problem: When i try to run my app to my iPhone after updating the OS to iOS8 not able to run.It says the error below Could Not launch "Myapp" process launch failed.Security. Solution: Settings -> General -> Device management -> Developer app -> Trust From some devices Settings -> General -> Profile. Before you run the app into your phone it will asking you to trust the app you can say yes.Otherwise it will say to no to run the app.

How to embed a custom font in my iOS application?

Solution: 1. First download the font file that you want to add in your iOS application with formate extension of .ttf 2.Add the file into your project 3.Add key in the info.plist with named "UIAppFonts".Save the plist 4.Use the font with the specified name 

continueUserActivity not called iOS swift

Problem: I had an app with sharing data from other apps to my app.If they click the url from whatsapp or others it will open my app and navigate to some page. Solution: func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool  not called because it was depricated. so try the below method func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool.