uikit

Which parts of UIKit, Core Graphics, Core Animation, OpenGL are allowed on non main-thread?

爷,独闯天下 提交于 2020-01-03 09:28:10
问题 In my OpenGL-ES 1.1 based app, I'm using CALayer s as a source for OpenGL textures. Those CALayer s comprise of CGImage s and text rendered through CoreGraphics. Another OpenGL texture source is a screenshot of a UIView taken using -[CALAyer renderInContext:] and UIGraphicsGetImageFromCurrentImageContext . Currently, I'm running completely on the main thread. The latter case in particular is pretty bad because it halts the OpenGL rendering for the whole time it takes to create the UIView and

Weak linking UIPopoverBackgroundView

邮差的信 提交于 2020-01-03 04:30:13
问题 I have a project that has to be deployed to 4.0 but has some features that are 5.0 only, such as UI customization. I want my UIPopoverBackgroundView subclass to be weak linked, but I always get the following error when launching on 4.X devices dyld: Symbol not found: _OBJC_CLASS_$_UIPopoverBackgroundView I can't use the NS_CLASS_AVAILABLE macro since my custom Background of the popover is a subclass of the UIPopoverBackgroundView class, so it has to be declared in a .h . How can I weak link

How do I draw text on a background thread in iOS?

为君一笑 提交于 2020-01-03 03:00:30
问题 I need to draw text on a background thread to save it as an image. I'm doing UIGraphicsPushContext() [NSString drawInRect:] UIGraphicsPopContext() The code works fine, but sometimes it crashes in drawInRect when I'm also drawing on the main thread at the same time. I tried to use NSAttributedString as suggested here: UIStringDrawing methods don't seem to be thread safe in iOS 6. But [NSAttributedString drawInRect:] doesn't seem to render anything on my background thread for some reason. Main

Reuse of UICollectionViewCells during scrolling

别等时光非礼了梦想. 提交于 2020-01-02 23:15:42
问题 I'm having an issue, I have a simple UICollectionView with a static 200 cells that load images from Flickr. my CellForItemAtIndexPath looks like this: - (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"FlickrCell" forIndexPath:indexPath]; cell.backgroundColor = [self generateRandomUIColor]; if(![[cell.subviews objectAtIndex:0] isKindOfClass:[PFImageView

Overlapping UIViews of Differing Color and Alpha

一个人想着一个人 提交于 2020-01-02 13:16:11
问题 Is there a way to overlap 2 or more UIViews with differing background colors and alphas to give the appearance of another color? For example place a red UIView on top of a blue UIView to give the appearance of a single magenta UIView . 回答1: On iOS the only blending mode for views if the so-called "source over" mode. Basically RGB_result = RGB_back * (1 - Alpha_front) + RGB_front * Alpha_front Thus a red (1, 0, 0) view with 0.5 alpha on top of a blue (0, 0, 1) view will result in dark magenta

How to unset delegate on UIView setAnimationDelegate: call?

孤街醉人 提交于 2020-01-02 12:27:59
问题 I am receiving crash reports that appear to be from a UIView animation calling a delegate that has been dealloced. Thread 0 Crashed: 0 libobjc.A.dylib 0x334776f6 objc_msgSend + 18 1 UIKit 0x31c566c4 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 2 UIKit 0x31c565d2 -[UIViewAnimationState animationDidStop:finished:] 3 QuartzCore 0x30045a26 run_animation_callbacks I am setting the current view controller as the delegate for animations using the following pattern: [UIView

How to unset delegate on UIView setAnimationDelegate: call?

两盒软妹~` 提交于 2020-01-02 12:26:10
问题 I am receiving crash reports that appear to be from a UIView animation calling a delegate that has been dealloced. Thread 0 Crashed: 0 libobjc.A.dylib 0x334776f6 objc_msgSend + 18 1 UIKit 0x31c566c4 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 2 UIKit 0x31c565d2 -[UIViewAnimationState animationDidStop:finished:] 3 QuartzCore 0x30045a26 run_animation_callbacks I am setting the current view controller as the delegate for animations using the following pattern: [UIView

becomeFirstResponder on UITextView not working

坚强是说给别人听的谎言 提交于 2020-01-02 08:12:33
问题 For some reason, I'm having trouble with making a textfield the first responder. I have a UITableView with two rows. Each row has a label and a UITextField. The textfields are tagged kLoginRowIndex = 0 and kPasswordRowIndex = 1. As you might have guessed, I use this for setting login and password. If the user taps on the return button when editing the login textfield, I want the password textfield to get the focus. Unfortunately, the password textfield doesn't accept the focus. Here is my

becomeFirstResponder on UITextView not working

你说的曾经没有我的故事 提交于 2020-01-02 08:11:51
问题 For some reason, I'm having trouble with making a textfield the first responder. I have a UITableView with two rows. Each row has a label and a UITextField. The textfields are tagged kLoginRowIndex = 0 and kPasswordRowIndex = 1. As you might have guessed, I use this for setting login and password. If the user taps on the return button when editing the login textfield, I want the password textfield to get the focus. Unfortunately, the password textfield doesn't accept the focus. Here is my

Why doesn't UIView (or it's subclasses) adopt the NSCopying Protocol?

隐身守侯 提交于 2020-01-02 07:35:09
问题 Can a Cocoahead please explain why UIView and it's sub classes don't adopt the NSCopying Protocol? I can see, philosophically, why UITouch would not be copy compliant, as it's a very temporal object. By UIView, and it's subclasses, especially UIButton, seem like they should be able to be copied. Certainly Apple has good reasons for doing things the way they do. Do you know their reason? 回答1: It would seem the question they asked wasn't "Why not?" but "Why do it?" There's little point to doing