cocoa-touch
How can I make text in a UILabel shrink font size
descriptionLabel.adjustsFontSizeToFitWidth = YES; descriptionLabel.minimumFontSize = 10.0; //adjust to preference obviously The following example is tested and verified on iPhone Simulator 3.1.2: UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 0, 200, 30)]; descriptionLabel.font = [UIFont systemFontOfSize:14.0]; descriptionLabel.minimumFontSize = 10.0; descriptionLabel.adjustsFontSizeToFitWidth = YES; descriptionLabel.numberOfLines = 1; descriptionLabel.text = @”supercalifragilisticexpialidocious even thought he sound of it is something quite … Read more
iPhone remove substring from string
NSString *str=@”1,2,3,4″; [str stringByReplacingOccurrencesOfString:@”3,” withString:@””]; That will remove ALL occurrences of @”3,” in str. If you want to remove only the first occurrence of @”3,”: NSString* str = @”1,2,3,4″; NSRange replaceRange = [str rangeOfString:@”3,”]; if (replaceRange.location != NSNotFound){ NSString* result = [str stringByReplacingCharactersInRange:replaceRange withString:@””]; } Hope this helps.
Get a user-readable version of the class name in swift (in objc NSStringFromClass was fine)
You can now just do: String(MyClass)
UITabBar(Controller) – Get index of tapped?
The answer depends on whether or not the UITabBar is managed by a UITabBarController or not. Case 1 – UITabBar is already handled by a UITabBarController Implement the UITabBarControllerDelegate protocol. Specifically the tabBarContoller:didSelectViewController: method. Set an instance of your class that implements the protocol as the delegate of the UITabBarController. – (void)tabBarController:(UITabBarController *)theTabBarController didSelectViewController:(UIViewController *)viewController … Read more
Hiding a UINavigationController’s UIToolbar during viewWillDisappear:
I too have experienced this problem. In my case, the only way I found to successfully hide the toolbar without showing the background of the window is to call [self.navigationController setToolbarHidden:YES animated:animated] in your view controller’s -viewDidAppear: method.