如何读取控制台中出现的错误代码?
<Warning>:  ....... -exited abnormally with signal 9: Killed: 9
<Warning>:  ....... -1 err = Bad file descriptor (0x00000009)
这里信号9意味着什么,除此之外还有更多的信号.任何可用的文档.
当一个应用程序,我得到这种错误.从Xcode启动的Xcode工具栏中的"停止"按钮终止.
{获得此错误的另一种方法是,按主页按钮,然后双击主页按钮并关闭应用程序.}
当我启动应用程序时,情况甚至会变得更糟.再次,通过点击应用程序.iPad屏幕上的图标,应用程序崩溃并抛出"libMobileGestalt copySystemVersionDictionaryValue:无法从系统版本字典中查找ReleaseType"
从查找堆栈溢出,我看到在iOS 6设备中发现此错误.
这个url声明它是一个SIGKILL错误,它发生在"应用程序立即终止,没有任何机会清理或捕获和处理信号"
因此,我认为在" - (void)didReceiveMemoryWarning"中释放objets无助于解决它,那么什么可以是一个明确的解决方案?
- (void)didReceiveMemoryWarning 
{
    [super didReceiveMemoryWarning];
    // Release objects.
    obj1 = nil;
    [view1 removeFromSuperView];
    view1 = nil;
    ...
}
何时复制块?该文档说,“当执行从定义的范围返回时,块将被删除。这意味着您不能直接从函数中返回它们。如果只能在定义范围仍在调用堆栈上时使用块,它们不会像实际那样有用”
因此,这是我尝试的代码,希望一旦在viewDidLoad中执行完成,该块将被删除。
MyReaderController.h
@interface MyReaderController : UIViewController
{
    myBlockVar aBlockVar;
}
-(myBlockVar) getABlock;
@end
MyReaderController.m
@implementation MyReaderController
- (void)viewDidLoad
{
    [super viewDidLoad];
    aBlockVar=[self getABlock];
    NSLog(@"Block Result = %f",aBlockVar(1));
}
-(void) viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    NSLog(@"Block Exists even after the execution completes=%@ %f",aBlockVar,aBlockVar(5));
}
-(myBlockVar) getABlock{
    return ^(int var){return 4.0f;};
}
@end
因此,此代码是否要求将viewDidLoad更改为以下代码,如果没有,那么我什么时候应该使用它。
- (void) viewDidLoad{
    [super viewDidLoad];
    aBlockVar=Block_copy([self getABlock]);
    NSLog(@"Block Result = %f",aBlockVar(1));
}
第2部分
稍后我尝试使用以下代码,希望现在它将在viewDidDisappear中将aBlockVar返回为nil obj。
- (void)viewDidLoad
{
    [super viewDidLoad];
    Blocker *blocker=[[Blocker alloc] init];
    myBlockVar myVar=[blocker getABlock];
    aBlockVar=myVar;
    NSLog(@"Block …要向UILabel添加背景渐变,请使用以下代码.
在使用渐变之前,UILabel看起来像这样.

现在,要添加渐变,我使用以下代码.
   CAGradientLayer *gradLayer=[CAGradientLayer layer];
    gradLayer.frame=self.myView.layer.bounds;
    [gradLayer setColors:[NSArray arrayWithObjects:(id)([UIColor redColor].CGColor), (id)([UIColor cyanColor].CGColor),nil]];
    gradLayer.endPoint=CGPointMake(1.0, 0.0);
    [self.myView.layer addSublayer:gradLayer];
UILabel然后如下,但没有文字.

我也尝试在UILabel图层的底部添加图层,但没有成功.
[self.myView.layer insertSublayer:gradLayer atIndex:0];
#define A7VERSION() ({[[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];})
#define IS_OS_7 A7VERSION()>=7
上述声明似乎编译得很好.
但是只要我添加一个.m文件,我就会得到以下异常"在预处理程序表达式启动时出现无效令牌".我无法理解我错在哪里
@implementation AppViewController
#if IS_OS_7
….
#else
….  
#endif
@end
画画
对于上面的内容和下面列出的代码,我得到以下输出.

可以在图像中找到所需输出的粗略概念.
-(id) initWithCoder:(NSCoder *)aDecoder{
    self=[super initWithCoder:aDecoder];
    if(self){
        self.clipsToBounds=YES;
        self.backgroundColor=[UIColor clearColor];
    }
    return self;
}
- (void)drawRect:(CGRect)rect
{
    // Drawing code
    CGFloat margin=2.0;
    CGRect outerRect=CGRectInset(rect, margin, margin);
    CGMutablePathRef path=createRoundedRectForRect(outerRect, 10.0);
    CGFloat margin1=1.0;
    CGRect innerRect=CGRectInset(outerRect, margin1, margin1);
    CGMutablePathRef innerPath=createRoundedRectForRect(innerRect, 5.0);
    CGContextRef context=UIGraphicsGetCurrentContext();
    CGContextSaveGState(context);
    CGContextAddPath(context, path);
    CGContextAddPath(context, innerPath);
    CGContextClip(context);
    CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor
                                    );
    CGContextStrokeRect(context, rect);
    CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor
                                   );
    CGContextFillRect(context, innerRect);
    CGContextRestoreGState(context);
}
CGMutablePathRef createRoundedRectForRect (CGRect rect, CGFloat radius){
    CGMutablePathRef path=CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, CGRectGetMaxX(rect), CGRectGetMinY(rect));
    CGPathAddArcToPoint(path, NULL, …我正在尝试将属性文本设置为标签.这些属性似乎是一种工作字体和颜色.
我唯一面临的问题是线条的包装.UILabel的大小为(200,300),numberofLines = 0.因此,它应该包裹线,但它不会发生.
   NSMutableString *title=[[NSMutableString alloc] init];
    NSRange range1;
    NSRange range2;
    NSRange range3;
        NSString *str1=@"ABCD EFGHI klm";
        [title appendString:str1];
        range1=NSMakeRange(0, str1.length);
        NSString *str2=@"PQRSSSS ";
        [title appendString:str2];
        range2=NSMakeRange(range1.length, str2.length);
        NSString *str3=@"1235 2347 989034 023490234 90";
        [title appendString:str3];
        range3=NSMakeRange(range2.location+range2.length, str3.length);
    NSMutableAttributedString *attributeText=[[NSMutableAttributedString alloc] initWithString:title];
    [attributeText setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:color1,NSForegroundColorAttributeName,[self getStlylishItalicFont:13.0] ,NSFontAttributeName,nil] range:range1];
    [attributeText setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:color2,NSForegroundColorAttributeName,[self getStylishFont:13.0] ,NSFontAttributeName,nil] range:range2];
    [attributeText setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:color3,NSForegroundColorAttributeName,[self getStylishBoldFont:13.0] ,NSFontAttributeName,nil] range:range3];
    self.myTextLabel.attributedText=attributeText;
UILabel显示如下,即使高度为300.
ABCD EFGHI klm PQRSSSS 1235 234 ...
ios ×4
objective-c ×3
cocoa-touch ×1
ios6 ×1
memory ×1
signals ×1
uilabel ×1
xcode ×1
xcode4.5 ×1
xcode4.6 ×1