uikit

Get UILabel out of UIButton

非 Y 不嫁゛ 提交于 2019-12-12 19:16:17
问题 I have an UIButton to which an UILabel was added as a subview. Is there an easy way to get the UILabel back out of it so I can change it's title ? 回答1: If you assign a tag to it while you still have a reference to it, you can later find it by searching for views with that tag . Like this: UILabel *label = [[UILabel alloc] init...]; label.tag = 1000; Later... UILabel *label = (UILabel *)[button viewWithTag:1000]; If there's no way for you to set the tag , you can also loop over the button's

how to perform a custom move of UITableViewCell?

ε祈祈猫儿з 提交于 2019-12-12 18:46:04
问题 I want to move cells just as these two methods do: - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath; - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath; Before I use these methods above to move cells (by user's touch action), tableView's setEditing:animated: must be called first. But what I want is user long press then drag a cell to move it without entering editing style,

Archiving and Unarchiving results in Bad Access

耗尽温柔 提交于 2019-12-12 16:30:50
问题 I'm having trouble setting up a model object to save the visual state of user generated CALayers in a simple graphics application for the iphone. I'm attempting to save the background color and frame of all the current layers on screen by passing those properties to model objects which implement the NSCoding protocol and then into an NSMutableArray which the app delegate owns. Then I archive the array with NSKeyedArchiver and store it in the NSUserDefaults. Each CALayer's backgroundColor

iOS面试题:简述性能优化

怎甘沉沦 提交于 2019-12-12 15:43:12
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 在性能优化中一个最具参考价值的属性是FPS:Frames Per Second,其实就是屏幕刷新率,苹果的iphone推荐的刷新率是60Hz,也就是说GPU每秒钟刷新屏幕60次,这每刷新一次就是一帧frame,FPS也就是每秒钟刷新多少帧画面。静止不变的页面FPS值是0,这个值是没有参考意义的,只有当页面在执行动画或者滑动的时候,FPS值才具有参考价值,FPS值的大小体现了页面的流畅程度高低,当低于45的时候卡顿会比较明显。 图层混合: 每一个layer是一个纹理,所有的纹理都以某种方式堆叠在彼此的顶部。对于屏幕上的每一个像素,GPU需要算出怎么混合这些纹理来得到像素RGB的值。 当Sa = 0.5时,RGB值为(0.5, 0, 0),可以看出,当两个不是完全不透明的CALayer覆盖在一起时,GPU大量做这种复合操作,随着这中操作的越多,GPU越忙碌,性能肯定会受到影响。 公式: R = S + D * ( 1 – Sa ) 结果的颜色是源色彩(顶端纹理)+目标颜色(低一层的纹理)*(1-源颜色的透明度)。 当Sa = 1时,R = S,GPU将不会做任何合成,而是简单从这个层拷贝,不需要考虑它下方的任何东西(因为都被它遮挡住了),这节省了GPU相当大的工作量。 一、入门级 1、用ARC管理内存 2

Why assign nil to IBOutlets in viewDidUnload?

筅森魡賤 提交于 2019-12-12 15:15:08
问题 I have a UIViewController that has an IBOutlet for a UILabel with the label wired up in the XIB. #import <Foundation/Foundation.h> @interface MyViewController : UIViewController { IBOutlet UILabel *aLabel; } @end According to iOS Programming: The Big Nerd Ranch Guide (2nd Edition) chapter 7 When [MyViewController] reloads its view, a new UILabel instance is created from the XIB file. Thus it recommends releasing the label in viewDidUnload . - (void)viewDidUnload { [super viewDidUnload];

Loading multiple images in same UIImageView flashes last image before showing new image

梦想与她 提交于 2019-12-12 13:40:23
问题 The goal is to render different images using the same UIImageView. Each time the user taps a different button, a different image gets rendered in the UIImageView. Example user flow: User taps button for image 1. UIImageView appears loaded with image 1. User taps different button to close UIImageView. UIImageView gets hidden. User taps different button for image 2. UIImageView is loaded with image 2 then unhidden. Image 1 appears for a moment before image 2 appears. This works the first time.

UIKit.h not found error

强颜欢笑 提交于 2019-12-12 12:46:58
问题 I made a single view app for the ipad, with a movie, webview and button, and I get this error when I try and run it. I have restarted the application, and reinstalled it, but nothing is working. This error keeps coming up in my MoviePlayer_Prefix.pch file. Can someone help me out? 回答1: It sounds like you removed the UIKit.framework from your project at some point. Check if it is listed in your project navigator. If it's not there, go to your project in the project navigator pane, select your

Force NSFetchedResultsController update when association count changes

谁都会走 提交于 2019-12-12 11:35:29
问题 I have an NSFetchedResultsController which displays a list of items in a table view, including a count of an associated entity. When an object is added for this association (using addXXXObject), no callbacks are called to notify my controller of the update. How can I receive a notification of an object being added to the parent entity's NSSet, or otherwise force the fetched results controller to update? To be clear, I'm currently retrieving the count using parent.children.count, which may be

Why not subclass UIApplication? Why use a delegate?

不问归期 提交于 2019-12-12 11:09:21
问题 Instead of using an application delegate so that the UIApplication singleton can call the delegate methods at predefined time, what are the advantages and disadvantages of just subclassing UIApplication ? ( update: why does the iOS architecture use the application delegate instead of letting people write an application by subclassing UIApplication and overriding its various methods?) That's because when we create a new UIView control, we subclass UIView ( update: or we subclass

UISlider with thumb center over the start and end of track

早过忘川 提交于 2019-12-12 10:59:17
问题 The default behaviour of UISlider is that its thumb isn't centered on start/end of track. Like below: I would like to modify it's behaviour to get: where thumb's center can be positioned on start or end. I have tried to cover start/end with empty UIView . Effect is that is look almost ok, but thumb has dropshadow that reveals my hack in some positions (which I can live with), however my hacky view covers a little the thumb and captures it's touch event (even when user interactions are