uikit

how to make round buttons like the iOS 7 lock screen

泪湿孤枕 提交于 2019-12-21 20:22:50
问题 Is there a predefined widget to make have round buttons in iOS7 like with the lock screen? I've been looking around at UIButton but I couldn't find anything. So their they're not UIButtons, or I'm not seeing it, or they just don't exist and I have to make my own custom buttons. 回答1: Link the framework in build steps then Import: #import QuartzCore/QuartzCore.h Code: self.fiveButton.layer.cornerRadius = self.fiveButton.bounds.size.width/2.0; self.fiveButton.layer.borderWidth = 1.0; self

Why is UIViewController deallocated on the main thread?

岁酱吖の 提交于 2019-12-21 19:11:32
问题 I recently stumbled upon The Deallocation Problem in some Objective-C code. This topic was discussed before on Stack Overflow in Block_release deallocating UI objects on a background thread. I think I understand the problem and its implications, but to be sure I wanted to reproduce it in a little test project. I first created my own SOUnsafeObject (= an object which should always be deallocated on the main thread). @interface SOUnsafeObject : NSObject @property (strong) NSString *title; -

UIScrollViewKeyboardDismissModeInteractive changing tableview height with keyboard

怎甘沉沦 提交于 2019-12-21 17:47:00
问题 Within a UIViewController I've set self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive . This is great because the user can drag the keyboard down from the tableview. However, the tableview maintains it's current height when dragging down the keyboard. This looks odd because it leaves empty space between the keyboard and the scrollview. How can I persistently track the frame of the keyboard so I may resize the tableview as the user drags the keyboard? I've tried

What's wrong with this randomize function?

心已入冬 提交于 2019-12-21 17:07:23
问题 I give it 0 and 400 and it returns me sometimes values above 400. That doesn't make sense. - (float)randomValueBetween:(float)low andValue:(float)high { return (((float) arc4random() / RAND_MAX) * (high - low)) + low; } that's actually a snippet I found on the net. Maybe someone can see the bug in there? 回答1: The manual page for arc4random indicates that the returned value can be anywhere in the range valid for u int32 (i.e. 0 to (2**32)-1 ). This means you'll want to divide by 0xFFFFFFFF ,

getting at a UIButton with the tag property IPhone

限于喜欢 提交于 2019-12-21 16:19:45
问题 I'm having a little trouble using the tag property to access a UIButton UIButton *randomButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect ]]; randomButton.frame = CGRectMake(205, 145, 90, 22); // size and position of button [randomButton setTitle:@"Random" forState:UIControlStateNormal]; randomButton.backgroundColor = [UIColor clearColor]; randomButton.adjustsImageWhenHighlighted = YES; [randomButton addTarget:self action:@selector(getrandom:) forControlEvents

iPhone - adapt images to retina display

最后都变了- 提交于 2019-12-21 13:09:31
问题 I have a question about updating my app's graphics for the retina display of the iPhone 4. I am keeping each view's resolution to 480 x 320 Points. So I was wondering: suppose I have a 100 x 50 UIImageView. It's better for my actual image I am going to load to be 200 x 100 pixels @ 163 ppi or 100 x 50 pixels @ 326 ppi? Is it the same thing in terms of 'lightness'? which is the preferred way? Thanks, you're awesome Lorenzo 回答1: 1) Define your UIImageView to be 100 x 50 pixels as you describe

Auto sizing UILabel when using Autolayout

吃可爱长大的小学妹 提交于 2019-12-21 12:21:49
问题 I'm creating a xib using autolayout (NSLayoutConsraint). Is there a way to use sizeToFit or something similar to make a UILabel fit its contents? I've tried setting a constraint of "greater than or equal to x" and tried setting the height to be below this. However, it keeps overwriting the height property. sitToFit doesn't seem to work when you have NSLayoutConstraints. How can I get the label to size appropriately? 回答1: Make an IBOutlet for your width and height constraints, and use

Which iOS classes that don't support zeroing weak references?

南楼画角 提交于 2019-12-21 11:54:46
问题 Is there a list of classes in iOS that can't be referred with a __weak pointer when using automatic reference counting (ARC)? Apple's Transitioning to ARC Release Notes only lists Mac classes so far: Which classes don’t support zeroing-weak references? You cannot currently create zeroing-weak references to instances of the following classes: NSATSTypesetter , NSColorSpace , NSFont , NSFontManager , NSFontPanel , NSImage , NSMenuView , NSParagraphStyle , NSSimpleHorizontalTypesetter ,

How to add a custom background to UISearchDisplayController's table view?

三世轮回 提交于 2019-12-21 09:28:53
问题 I want to add a custom UIImageView to UISearchDisplayController's table view background and set table view's background color to clearColor. Tried a few different approach but couldn't find the right solution. Any idea how to approach this? Note: I don't want to add to searchDisplayController's searchResultsTableView's view hierarchy, but rather overlay another sibling view below it) 回答1: You can set the background image in a similar way you would for your main table, only set it in the

UIBarButtonItems shift position when UINavigationController is presented modally

时光总嘲笑我的痴心妄想 提交于 2019-12-21 07:55:15
问题 I'm presenting a UINavigationController modally, from within an iOS app extension: UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; nav.modalPresentationStyle = UIModalPresentationFormSheet; nav.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentViewController:nav animated:YES completion:nil]; When the navigation controller appears, its root view controller's UIBarButtonItems jump position: I'm creating and adding the buttons