Tag: cocoa touch

两个UITableView在同一视图中

我想知道是否允许在同一个视图中使用多个UItableView (我没有看到苹果的人机接口指南中的任何东西),如果没关系,如何在每个UITableView viewDidLoad加载不同的DataSource ?

拆卸UIViewController时总是调用viewDidUnload和dealloc?

我想知道在UIViewController拆除过程中是否总是调用viewDidUnload和dealloc 。 有没有可能dealloc可以调用我的视图控制器没有viewDidUnload被首先调用? 无论哪种情况,如果我安全地释放了这两个方法中的属性并保留了引用,那么调用这两种方法都不会成为问题 – 但是我想知道是否有人确切地知道或者可以揭示拆除处理。 2012更新:这是很方便的注意,如果iOS 6的viewDidUnload已被弃用,应该replace为手动视图拆卸, 如果需要在didReceiveMemoryWarning 。 一个关于新的UIView / UIViewContoller的好文章,以及新的行为,它对joe conway博客的影响

圆弧段的笔画animation以完整笔画结束

我正在试图创build一个圆的一部分的外观animation。 为了存档,我使用了安静的CABasicAnimations。 animation从上面开始,很好地移动到整个圈子的三分之一。 但是当animation结束时,圈子正在被完全画出。 我怎样才能防止呢? 这是我的自定义UIView的源代码: – (void)drawRect:(CGRect)rect { int radius = 100; int strokeWidth = 10; CGColorRef color = [UIColor redColor].CGColor; int timeInSeconds = 5; CGFloat startAngle = 0; CGFloat endAngle = 0.33; CAShapeLayer *circle = [CAShapeLayer layer]; circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius].CGPath; circle.position = CGPointMake(CGRectGetMidX(self.frame)-radius, CGRectGetMidY(self.frame)-radius); circle.fillColor = [UIColor clearColor].CGColor; […]

如何旋转任意点周围的对象?

我想旋转一个UILabel在一个圆形的任意点,而不是一条直线。 这是我的代码。最后一点是完美的,但它在初始点和结束点之间是一条直线。 – (void)rotateText:(UILabel *)label duration:(NSTimeInterval)duration degrees:(CGFloat)degrees { /* Setup the animation */ [UILabel beginAnimations:nil context:NULL]; [UILabel setAnimationDuration:duration]; CGPoint rotationPoint = CGPointMake(160, 236); CGPoint transportPoint = CGPointMake(rotationPoint.x – label.center.x, rotationPoint.y – label.center.y); CGAffineTransform t1 = CGAffineTransformTranslate(label.transform, transportPoint.x, -transportPoint.y); CGAffineTransform t2 = CGAffineTransformRotate(label.transform,DEGREES_TO_RADIANS(degrees)); CGAffineTransform t3 = CGAffineTransformTranslate(label.transform, -transportPoint.x, +transportPoint.y); CGAffineTransform t4 = CGAffineTransformConcat(CGAffineTransformConcat(t1, t2), t3); label.transform […]

如何为两个PNG图像之间的UIButton制作animation?

我有两个我想用作button的PNG。 如何通过在这两个图像之间快速切换来animationUIButton?

Swift 3 ObjC可选协议方法不在子类中调用

我有以下类层次结构: class ScrollableViewController: UIViewController, UITableViewDelegate { // … } 这实现了一个UITableViewDelegate协议方法,例如tableView:willDisplayCellAt: 在我的类SpecificScrollableViewController ,inheritance自ScrollableViewController ,新的可选协议方法不会再被调用,例如tableView(_:heightForRowAt:)

在运行时循环所有对象属性

我想创build一个Objective-C基类,在运行时对所有属性(不同types)执行操作。 由于属性的名称和types不总是被知道,我怎么能做这样的事情呢? @implementation SomeBaseClass – (NSString *)checkAllProperties { for (property in properties) { // Perform a check on the property } } 编辑:这将是特别有用的自定义- (NSString *)description:覆盖。

UITextView在iOS7中的内容大小不同

我正在使用一个UITextView ,通过点击一个“更多”button可以扩展。 问题如下: 在iOS6上我使用这个, self.DescriptionTextView.text = @"loong string"; if(self.DescriptionTextView.contentSize.height>self.DescriptionTextView.frame.size.height) { //set up the more button } 问题是在iOS7上, contentSize.height返回一个不同的值(远小于它在iOS6上返回的值)。 为什么是这样? 如何解决它?

使用MapKit和CoreLocation时的Xcode警告

我试图使用实现MKMapView的实例,使用CoreLocation跟踪用户的位置,然后放大到他们在哪里。 我只想跟踪用户的位置,当我在前台。 由于我的应用程序是针对iOS8,我有一个关键的NSLocationWhenInUseUsageDescription plist入口。 当我第一次运行应用程序时,应用程序会正确地询问是否可以访问我的位置。 当我点击“允许”后,我收到来自Xcode的以下警告: Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first. …这有点令人困惑,因为我实际上正在调用requestWhenInUseAuthorization ,在我的代码中可以看到: @property (strong, nonatomic) IBOutlet MKMapView *mapView; @property(nonatomic, retain) CLLocationManager *locationManager; @end @implementation MapView – (void)viewDidLoad { [super viewDidLoad]; [self locationManager]; [self updateLocation]; } – (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; […]

asynchronous下载图片

我需要从网上下载图像并将其显示在ImageView 。 目前我正在使用SDWebImage (这是一个具有caching支持的asynchronous图像下载器,具有UIImageView类别)。 但是,当我点击后退button和前进button时(当我试图重复来回查看视图时),它会崩溃。 无论如何,这很less发生,但我需要摆脱这个错误。 是否有任何其他库(不使用私有API),我可以在我的项目中使用?