如何才能在iOS中获得屏幕的尺寸?
目前,我使用:
lCurrentWidth = self.view.frame.size.width;
lCurrentHeight = self.view.frame.size.height;
Run Code Online (Sandbox Code Playgroud)
在viewWillAppear:和willAnimateRotationToInterfaceOrientation:duration:
我第一次得到整个屏幕尺寸.第二次我屏幕减去导航栏.
我正在玩绘图路径,我注意到至少在某些情况下,UIBezierPath优于我认为的Core Graphics等价物.-drawRect:下面的方法创建两个路径:一个UIBezierPath和一个CGPath.除了它们的位置之外,路径是相同的,但是抚摸CGPath所需的时间大约是抚摸UIBezierPath的两倍.
- (void)drawRect:(CGRect)rect
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
// Create the two paths, cgpath and uipath.
CGMutablePathRef cgpath = CGPathCreateMutable();
CGPathMoveToPoint(cgpath, NULL, 0, 100);
UIBezierPath *uipath = [[UIBezierPath alloc] init];
[uipath moveToPoint:CGPointMake(0, 200)];
// Add 200 curve segments to each path.
int iterations = 200;
CGFloat cgBaseline = 100;
CGFloat uiBaseline = 200;
CGFloat xincrement = self.bounds.size.width / iterations;
for (CGFloat x1 = 0, x2 = xincrement;
x2 < self.bounds.size.width;
x1 = x2, x2 += xincrement)
{ …Run Code Online (Sandbox Code Playgroud) 我想要这样的东西:
CGPoint a = CGPointMake(1, 1);
CGPoint b = CGPointMake(1, 1);
if ([CGHelperClass compareCGPoint:a to:b]){
//do something
}
Run Code Online (Sandbox Code Playgroud)
我知道写自己是微不足道的,但我很好奇它是否已经存在于某个地方.
我想知道是否可以通过iPhone模拟器发送电子邮件.我看过通过iphone发送电子邮件的教程如下:
http://www.edumobile.org/iphone/iphone-programming-tutorials/compose-mail-application-in-iphone/
现在要测试它是否有必要拥有真正的设备?如果我想通过iPhone模拟器发送电子邮件的方式是什么?
我刚刚开发了一个应用程序,但是当在模拟器中运行时,调试器控制台会说:
The app delegate must implement the window property if it wants to use
a main storyboard file.
Run Code Online (Sandbox Code Playgroud)
我有一个app委托文件.消息的含义是什么,以及如何让我的应用程序运行?
我试图抓住一个手势,但它不起作用.这是我的代码:
UISwipeGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionLeft)];
[[self view] addGestureRecognizer:recognizer];
[recognizer release];
Run Code Online (Sandbox Code Playgroud)
和
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
NSLog(@"get gesture");
if (recognizer.direction == UISwipeGestureRecognizerDirectionRight) {
NSLog(@"get gesture right");
}
if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"get gesture Left");
}
}
Run Code Online (Sandbox Code Playgroud)
它总是得到一个手势,但不认识方向.我也试过if(recognizer.direction){NSLog(@"get gesture");},它也有效,所以我不明白我犯了哪个错误.
谢谢你的帮助.
有人请解释转发和委托之间的区别吗?它们看起来很相似,但我还没有找到一个好的转发定义,所以我不确定我是否真的理解.
通常我会在AppDelegate中初始化我的模型类变量,以便不同的ViewControllers可以使用它们,而无需跨类文件传递它们的实例.但是,每次我将AppDelegate导入.m文件以访问这些变量的数据时,我觉得我做错了.
这是访问这些变量的正确方法还是我应该采取不同的方式?
编辑: 我的问题不是如何访问变量.我目前使用这行代码来获取我的appDelegate实例:
id appDelegate = [[UIApplication sharedApplication] delegate];
从概念上讲,我想知道这是否是与应用程序的模型类交互的可接受方式.对我来说,似乎应用程序的AppDelegate整体管理应用程序.因此,将此类导入到应用程序类链中的其他类中似乎违反直觉.
model-view-controller dependencies cocoa-touch uiapplicationdelegate ios
在Objective C中创建自定义类时,该dealloc方法何时以及如何调用?这是我必须在课堂上以某种方式实现的吗?
我正在使用cocos2d框架进行iOS游戏开发,我非常羡慕Eclipse Java程序员在调试应用程序时热交换代码的能力(即更改方法中的变量值并使程序实时更新,就像你有一个REPL而不必重新编译).
对于iOS开发来说,这似乎是非常有用的东西,我的开发环境(显然)是Xcode,而我正在编程的语言是Objective C.我已经google了一下但却找不到任何东西 - 所以我想我会问社区.
有没有人知道在Objective C中编程时是否有办法在Xcode中使用Hot Swap代码?
提前致谢
ios ×5
iphone ×4
objective-c ×4
cocoa-touch ×3
xcode ×3
bezier ×1
c++ ×1
class ×1
dealloc ×1
delegation ×1
dependencies ×1
drawing ×1
email ×1
forwarding ×1
gesture ×1
hotswap ×1
message ×1
oop ×1
screen ×1
sendmessage ×1
simulator ×1
swift ×1
uikit ×1