小编Ila*_*ian的帖子

使用CGAffineTransform缩放并设置锚点

如果我理解正确的缩放UIViewCGAffineTransform锚改造中心.

特别是:

self.frame = CGRectMake(0,0,100,100);
self.transform = CGAffineTransformMakeScale(2, 2);
NSLog(@"%f;%f;%f;%f", self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height); 
Run Code Online (Sandbox Code Playgroud)

打印:

-50;-50;200;200
Run Code Online (Sandbox Code Playgroud)

如何创建使用特定锚点(例如0; 0)的CGAffineTransform比例?

iphone scaling cgaffinetransform ios

30
推荐指数
2
解决办法
6万
查看次数

Cocoa-Touch - 代表混淆

我刚刚开始运行Xcode 4.2.1和iOS5 SDK的新项目.该项目是使用ARC设置的.我正在尝试将AppDelegate设置为UITabBarController的委托,[tabBarController setDelegate:self];如果我这样做,我会收到一条警告消息:

warning: Semantic Issue: Sending 'AppDelegate *const __strong' to parameter of incompatible type 'id<UITabBarControllerDelegate>'
Run Code Online (Sandbox Code Playgroud)

好吧,我设置我的AppDelegate以符合UITabBarControllerDelegate

@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>
Run Code Online (Sandbox Code Playgroud)

好的,警告消失了.

我现在得到另一个错误.在一个视图控制器中,我希望得到一个AppDelegate,所以我这样做:AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];但这会发出警告说:

warning: Semantic Issue: Initializing 'AppDelegate *__strong' with an expression of incompatible type 'id<UIApplicationDelegate>'
Run Code Online (Sandbox Code Playgroud)

但如果我删除我的AppDelegate符合UITabControllerDelegate协议我的第二个警告消失.

非常奇怪的行为,是什么让Cocoa专家?

cocoa-touch delegates objective-c uiapplicationdelegate automatic-ref-counting

27
推荐指数
1
解决办法
9862
查看次数

如何确定CGPath的交集

我的问题类似于.

我有2个CGPathRef,1个将通过手指触摸移动.我想找到2 CGPathRef是否相交?这个问题大约在2年前被问到,我想知道是否在某些时候找到了一些东西.

iphone objective-c

17
推荐指数
2
解决办法
7884
查看次数

昨天在Objective-c中获得NSDate

我需要使用NSDate对象获取昨天的日期.任何的想法?

编辑:解决:

NSDate *yesterday = [NSDate dateWithTimeIntervalSinceNow:-86400];

cocoa-touch objective-c nsdate

9
推荐指数
2
解决办法
8607
查看次数

变量具有不完整类型'struct sockaddr_in'

我试着用

 struct sockaddr_in sin;
Run Code Online (Sandbox Code Playgroud)

但是,如果我使用它,我得到

Variable has incomplete type 'struct sockaddr_in' 
Run Code Online (Sandbox Code Playgroud)

Forward declaration of 'struct sockaddr_in'
Run Code Online (Sandbox Code Playgroud)

作为错误.我使用Xcode4时出错.在Xcode3.2中它可以工作.有人知道如何解决这个错误吗?我的进口是

#import <sys/socket.h>
#import <netinet/in.h>
#import <netinet6/in6.h>
#import <arpa/inet.h>
#import <ifaddrs.h>
#include <netdb.h>
#import <SystemConfiguration/SCNetworkReachability.h>
Run Code Online (Sandbox Code Playgroud)

iphone compiler-errors objective-c ios ios5

5
推荐指数
1
解决办法
1万
查看次数

如何动画UIView与presentModalViewController的工作相同(即[self presentModalViewController:child animated:YES];)

我是ios开发的新手,现在我在我的应用程序上做了一些动画.我的应用程序在主视图底部有一个菜单,有两个按钮用于隐藏菜单,另外用于显示菜单.我需要的是节目菜单的隐藏功能 [self presentModalViewController:menuView animated:YES];[self dismissModalViewControllerAnimated:YES];功能一样(即单击显示按钮,从主视图底部弹出menuView,然后单击隐藏按钮,向下移动菜单视图).我知道基本动画如:

[UIView beginAnimations:@"ShowHideView" context:nil];

[UIView setAnimationCurve:UIViewAnimationOptionOverrideInheritedCurve];

[UIView setAnimationDuration:1.0];

[UIView setAnimationDelegate:self];
[menuView setAlpha:0];

[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

如果有人知道,请帮助我.

animation objective-c uiview ios4 xcode4

3
推荐指数
1
解决办法
1361
查看次数

iPhone 5错误的屏幕高度

我在3.5英寸屏幕上开发了一个应用程序,现在我为4英寸屏幕做了一个新的故事板,我喜欢跟随在appdelegate上的故事板之间切换,我记录了屏幕高度,它给了我480.00000检查它:

NSLog(@"Checking Screen Size");
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{    
    NSLog(@"On iPhone");
    CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;

    if (iOSDeviceScreenSize.height == 480)
    {   (diagonally measured)
        NSLog(@"iPhone 4: %f", iOSDeviceScreenSize.height);
}
if (iOSDeviceScreenSize.height == 568)
{   
        NSLog(@"iPhone 5: %f", iOSDeviceScreenSize.height);
}
Run Code Online (Sandbox Code Playgroud)

我的手机是iPhone 5,NSLog给了我480.0000

ios ios5

3
推荐指数
1
解决办法
699
查看次数

从AVCaptureSession捕获图像

我正在学习AVCaptureSession以及如何使用其委托方法捕获多个图像

- (void)captureOutput:(AVCaptureOutput *)captureOutput 
     didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer 
     fromConnection:(AVCaptureConnection *)connection
Run Code Online (Sandbox Code Playgroud)

我的目标是以每秒预定义的速率捕获1个或多个图像.例如,每1秒1或2个图像.所以我订了

 AVCaptureVideoDataOutput *captureOutput = [[AVCaptureVideoDataOutput alloc] init];
 captureOutput.alwaysDiscardsLateVideoFrames = YES; 
 captureOutput.minFrameDuration = CMTimeMake(1, 1);
Run Code Online (Sandbox Code Playgroud)

[self.captureSession startRunning];开始我的日志文件显示委托被称为20次.它来自何处以及如何以我预期的间隔捕获图像?

iphone objective-c calayer uiimageview avcapturesession

2
推荐指数
1
解决办法
2万
查看次数

iPhone应用程序邮件中没有返回应用程序

我是iOS开发的新手.我创建了一个iOS应用程序.在我的应用程序中,当检测到电子邮件时,我编写了代码以在iPhone中启动默认电子邮件应用程序.

到此为止,它运作良好.默认的iPhone撰写邮件界面正在启动,我可以发送邮件.

但问题是在发送邮件后,控件没有返回到应用程序.我该怎么做才能将控件恢复到我的应用程序?

专家请帮忙.

iphone sendmail ios ios5

2
推荐指数
1
解决办法
515
查看次数

在NSString中复制,保留和引用计数

当我使用copy时保留了什么,保留NSString属性并将其分配给局部变量?

@interface SomeClass : NSObject 
{ 
   NSString *name; 
   NSString *name2;
} 

@property (nonatomic, retain) NSString* name1;
@property (nonatomic, copy) NSString *name2; 
Run Code Online (Sandbox Code Playgroud)

如果我将string的值赋给另一个NSString变量,如:

NSString *newString1 = name1;
NSString *newString2 = name2;
Run Code Online (Sandbox Code Playgroud)

什么将保留name1和name2的数量?

NSString *anotherString1 = [NSString alloc]initWithString:name1];
NSString *anotherString2 = [NSString alloc]initWithString:name2];
Run Code Online (Sandbox Code Playgroud)

这里名字1和名字2的保留计数是多少?

copy objective-c retain ios retaincount

1
推荐指数
1
解决办法
2556
查看次数