2012-12-04 52 views
-1

有人可以帮我解释为什么升级到最新版本的xcode后出现这个错误吗?该应用程序在此之前工作正常,但此语法错误现在无法编译。我得到的错误在 #pragma mark [email protected] (nonatomic, k Constants, 也我得到一个缺少@end错误。xcode升级后xcode出现意外'@'

对不起张贴整个页面,但我想确保我提供足够的帮助。

#import "MBProgressHUD.h" 

@interface MBProgressHUD() 

(void)hideUsingAnimation:(BOOL)animated; 
(void)showUsingAnimation:(BOOL)animated; 

(void)fillRoundedRect:(CGRect)rect inContext:(CGContextRef)context; 

(void)done; 
(void)updateLabelText:(NSString *)newText; 
(void)updateDetailsLabelText:(NSString *)newText; 
(void)updateProgress; 
(void)updateIndicators; 

(void)handleGraceTimer:(NSTimer *)theTimer; 
(void)handleMinShowTimer:(NSTimer *)theTimer; 

@property (retain) UIView *indicator; 

@property (assign) float width; 
@property (assign) float height; 

@property (retain) NSTimer *graceTimer; 
@property (retain) NSTimer *minShowTimer; 

@property (retain) NSDate *showStarted; 

@end 


@implementation MBProgressHUD 

#pragma mark - 
#pragma mark Accessors 

@synthesize mode; 

@synthesize delegate; 
@synthesize labelText; 
@synthesize detailsLabelText; 
@synthesize opacity; 
@synthesize labelFont; 
@synthesize detailsLabelFont; 
@synthesize progress; 

@synthesize indicator; 

@synthesize width; 
@synthesize height; 
@synthesize xOffset; 
@synthesize yOffset; 

@synthesize graceTime; 
@synthesize minShowTime; 
@synthesize graceTimer; 
@synthesize minShowTimer; 
@synthesize taskInProgress; 

@synthesize showStarted; 

(void)setMode:(MBProgressHUDMode)newMode { 

if (mode && (mode == newMode)) { 
return; 
} 

mode = newMode; 

[self performSelectorOnMainThread:@selector(updateIndicators) withObject:nil waitUntilDone:NO]; 
[self performSelectorOnMainThread:@selector(setNeedsLayout) withObject:nil waitUntilDone:NO]; 
[self performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO]; 
} 

(void)setLabelText:(NSString *)newText { 
[self performSelectorOnMainThread:@selector(updateLabelText:) withObject:newText waitUntilDone:NO]; 
[self performSelectorOnMainThread:@selector(setNeedsLayout) withObject:nil waitUntilDone:NO]; 
[self performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO]; 
} 

(void)setDetailsLabelText:(NSString *)newText { 
[self performSelectorOnMainThread:@selector(updateDetailsLabelText:) withObject:newText waitUntilDone:NO]; 
[self performSelectorOnMainThread:@selector(setNeedsLayout) withObject:nil waitUntilDone:NO]; 
[self performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO]; 
} 

(void)setProgress:(float)newProgress { 
progress = newProgress; 

if (mode == MBProgressHUDModeDeterminate) { 
[self performSelectorOnMainThread:@selector(updateProgress) withObject:nil waitUntilDone:NO]; 
[self performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO]; 
} 
} 

#pragma mark - 
#pragma mark Accessor helpers 

(void)updateLabelText:(NSString *)newText { 
if (labelText != newText) { 
[labelText release]; 
labelText = [newText copy]; 
} 
} 

(void)updateDetailsLabelText:(NSString *)newText { 
if (detailsLabelText != newText) { 
[detailsLabelText release]; 
detailsLabelText = [newText copy]; 
} 
} 

(void)updateProgress { 
[(MBRoundProgressView *)indicator setProgress:progress]; 
} 

(void)updateIndicators { 
if (indicator) { 
[indicator removeFromSuperview]; 
} 

self.indicator = nil; 

if (mode == MBProgressHUDModeDeterminate) { 
self.indicator = [[MBRoundProgressView alloc] initWithDefaultSize]; 
} 
else { 
self.indicator = [[UIActivityIndicatorView alloc] 
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 
[(UIActivityIndicatorView *)indicator startAnimating]; 
} 

[self addSubview:indicator]; 
} 

**#pragma mark - 
@property (nonatomic, k Constants** 

#define MARGIN 20.0 
#define PADDING 4.0 

#define LABELFONTSIZE 22.0 
#define LABELDETAILSFONTSIZE 16.0 

#define PI 3.14159265358979323846 

#pragma mark - 
#pragma mark Lifecycle methods 

(id)initWithWindow:(UIWindow *)window { 
@property (nonatomic, nonatomic, nonatomic, [self initWithView:window]; 
} 

(id)initWithView:(UIView *)view { 
initializer above) 
if (!view) { 
@property (nonatomic, ion raise:@"MBProgressHUDViewIsNillException" 
format:@"The view used in the MBProgressHUD initializer is nil."]; 
} 
return [self initWithFrame:view.bounds]; 
} 

(id)initWithFrame:(CGRect)frame { 
if (self = [super initWithFrame:frame]) { 

self.mode = MBProgressHUDModeIndeterminate; 
self.labelText = nil; 
self.detailsLabelText = nil; 
self.opacity = 0.9; 
self.labelFont = [UIFont boldSystemFontOfSize:LABELFONTSIZE]; 
self.detailsLabelFont = [UIFont boldSystemFontOfSize:LABELDETAILSFONTSIZE]; 
self.xOffset = 0.0; 
self.yOffset = 0.0; 
self.graceTime = 0.0; 
self.minShowTime = 0.0; 

self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 


self.opaque = NO; 
self.backgroundColor = [UIColor clearColor]; 

self.alpha = 0.0; 


label = [[UILabel alloc] initWithFrame:self.bounds]; 


detailsLabel = [[UILabel alloc] initWithFrame:self.bounds]; 

taskInProgress = NO; 
} 
return self; 
} 

(void)dealloc { 
[indicator release]; 
[label release]; 
[detailsLabel release]; 
[labelText release]; 
[detailsLabelText release]; 
[graceTimer release]; 
[minShowTimer release]; 
[showStarted release]; 
[super dealloc]; 
} 

#pragma mark - 
#pragma mark Layout 

(void)layoutSubviews { 
CGRect frame = self.bounds; 


@property (nonatomic, indFrame = indicator.bounds; 
self.width = indFrame.size.width + 2 * MARGIN; 
self.height = indFrame.size.height + 2 * MARGIN; 


indFrame.origin.x = floor((frame.size.width - indFrame.size.width)/2) + self.xOffset; 
indFrame.origin.y = floor((frame.size.height - indFrame.size.height)/2) + self.yOffset; 
indicator.frame = indFrame; 


if (nil != self.labelText) { 

CGSize dims = [self.labelText sizeWithFont:self.labelFont]; 

clip the label width 
float lHeight = dims.height; 
float lWidth; 
if (dims.width <= (frame.size.width - 2 * MARGIN)) { 
lWidth = dims.width; 
} 
else { 
lWidth = frame.size.width - 4 * MARGIN; 
} 

label.font = self.labelFont; 
label.adjustsFontSizeToFitWidth = NO; 
label.textAlignment = UITextAlignmentCenter; 
label.opaque = NO; 
label.backgroundColor = [UIColor clearColor]; 
label.textColor = [UIColor whiteColor]; 
label.text = self.labelText; 

if (self.width < (lWidth + 2 * MARGIN)) { 
self.width = lWidth + 2 * MARGIN; 
} 
self.height = self.height + lHeight + PADDING; 


indFrame.origin.y -= (floor(lHeight/2 + PADDING/2)); 
indicator.frame = indFrame; 

// Set the label position and dimensions 
CGRect lFrame = CGRectMake(floor((frame.size.width - lWidth)/2) + xOffset, 
floor(indFrame.origin.y + indFrame.size.height + PADDING), 
lWidth, lHeight); 
label.frame = lFrame; 

[self addSubview:label]; 

// Add details label delatils text was set 
if (nil != self.detailsLabelText) { 
// Get size of label text 
dims = [self.detailsLabelText sizeWithFont:self.detailsLabelFont]; 

// Compute label dimensions based on font metrics if size is larger than max then clip the label width 
lHeight = dims.height; 
if (dims.width <= (frame.size.width - 2 * MARGIN)) { 
lWidth = dims.width; 
} 
else { 
lWidth = frame.size.width - 4 * MARGIN; 
} 

// Set label properties 
detailsLabel.font = self.detailsLabelFont; 
detailsLabel.adjustsFontSizeToFitWidth = NO; 
detailsLabel.textAlignment = UITextAlignmentCenter; 
detailsLabel.opaque = NO; 
detailsLabel.backgroundColor = [UIColor clearColor]; 
detailsLabel.textColor = [UIColor whiteColor]; 
detailsLabel.text = self.detailsLabelText; 

// Update HUD size 
if (self.width < lWidth) { 
self.width = lWidth + 2 * MARGIN; 
} 
self.height = self.height + lHeight + PADDING; 
// Move indicator to make room for the new label 
indFrame.origin.y -= (floor(lHeight/2 + PADDING/2)); 
indicator.frame = indFrame; 

// Move first label to make room for the new label 
lFrame.origin.y -= (floor(lHeight/2 + PADDING/2)); 
label.frame = lFrame; 

// Set label position and dimensions 
CGRect lFrameD = CGRectMake(floor((frame.size.width - lWidth)/2) + xOffset, 
lFrame.origin.y + lFrame.size.height + PADDING, lWidth, lHeight); 
detailsLabel.frame = lFrameD; 

[self addSubview:detailsLabel]; 
} 
} 
} 

#pragma mark - 
#pragma mark Showing and execution 

- (void)show:(BOOL)animated { 
useAnimation = animated; 

// If the grace time is set postpone the HUD display 
if (self.graceTime > 0.0) { 
self.graceTimer = [NSTimer scheduledTimerWithTimeInterval:self.graceTime 
target:self 
                 selector:@selector(handleGraceTimer:) 
userInfo:nil 
repeats:NO]; 
} 
// ... otherwise show the HUD imediately 
else { 
[self setNeedsDisplay]; 
[self showUsingAnimation:useAnimation]; 
} 
} 

- (void)hide:(BOOL)animated { 
useAnimation = animated; 

// If the minShow time is set, calculate how long the hud was shown, 
// and pospone the hiding operation if necessary 
if (self.minShowTime > 0.0 && showStarted) { 
NSTimeInterval interv = [[NSDate date] timeIntervalSinceDate:showStarted]; 
if (interv < self.minShowTime) { 
self.minShowTimer = [NSTimer scheduledTimerWithTimeInterval:(self.minShowTime - interv) 
target:self 
                   selector:@selector(handleMinShowTimer:) 
userInfo:nil 
repeats:NO]; 
return; 
} 
} 

// ... otherwise hide the HUD immediately 
[self hideUsingAnimation:useAnimation]; 
} 

- (void)handleGraceTimer:(NSTimer *)theTimer { 
// Show the HUD only if the task is still running 
if (taskInProgress) { 
[self setNeedsDisplay]; 
[self showUsingAnimation:useAnimation]; 
} 
} 

- (void)handleMinShowTimer:(NSTimer *)theTimer { 
[self hideUsingAnimation:useAnimation]; 
} 

- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated { 

methodForExecution = method; 
targetForExecution = [target retain]; 
objectForExecution = [object retain]; 

// Launch execution in new thread 
taskInProgress = YES; 
[NSThread detachNewThreadSelector:@selector(launchExecution) toTarget:self withObject:nil]; 

// Show HUD view 
[self show:animated]; 
} 

- (void)launchExecution { 
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 

// Start executing the requested task 
[targetForExecution performSelector:methodForExecution withObject:objectForExecution]; 

// Task completed, update view in main thread (note: view operations should 
// be done only in the main thread) 
[self performSelectorOnMainThread:@selector(cleanUp) withObject:nil waitUntilDone:NO]; 

[pool release]; 
} 

- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void*)context { 
[self done]; 
} 

- (void)done { 
isFinished = YES; 

// If delegate was set make the callback 
self.alpha = 0.0; 

if(delegate != nil && [delegate conformsToProtocol:@protocol(MBProgressHUDDelegate)]) { 
if([delegate respondsToSelector:@selector(hudWasHidden)]) { 
[delegate performSelector:@selector(hudWasHidden)]; 
} 
} 
} 

- (void)cleanUp { 
taskInProgress = NO; 

self.indicator = nil; 

[targetForExecution release]; 
[objectForExecution release]; 

[self hide:useAnimation]; 
} 

#pragma mark - 
#pragma mark Fade in and Fade out 

- (void)showUsingAnimation:(BOOL)animated { 
self.showStarted = [NSDate date]; 
// Fade in 
if (animated) { 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.40]; 
self.alpha = 1.0; 
[UIView commitAnimations]; 
} 
else { 
self.alpha = 1.0; 
} 
} 

- (void)hideUsingAnimation:(BOOL)animated { 
// Fade out 
if (animated) { 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.40]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(animationFinished: finished: context:)]; 
// 0.02 prevents the hud from passing through touches during the animation the hud will get completely hidden 
// in the done method 
self.alpha = 0.02; 
[UIView commitAnimations]; 
} 
else { 
self.alpha = 0.0; 
[self done]; 
} 
} 

#pragma mark BG Drawing 

- (void)drawRect:(CGRect)rect { 
// Center HUD 
CGRect allRect = self.bounds; 
// Draw rounded HUD bacgroud rect 
CGRect boxRect = CGRectMake(((allRect.size.width - self.width)/2) + self.xOffset, 
           ((allRect.size.height - self.height)/2) + self.yOffset, self.width, self.height); 
CGContextRef ctxt = UIGraphicsGetCurrentContext(); 
[self fillRoundedRect:boxRect inContext:ctxt]; 
} 

- (void)fillRoundedRect:(CGRect)rect inContext:(CGContextRef)context { 
float radius = 10.0f; 

CGContextBeginPath(context); 
CGContextSetGrayFillColor(context, 0.0, self.opacity); 
CGContextMoveToPoint(context, CGRectGetMinX(rect) + radius, CGRectGetMinY(rect)); 
CGContextAddArc(context, CGRectGetMaxX(rect) - radius, CGRectGetMinY(rect) + radius, radius, 3 * M_PI/2, 0, 0); 
CGContextAddArc(context, CGRectGetMaxX(rect) - radius, CGRectGetMaxY(rect) - radius, radius, 0, M_PI/2, 0); 
CGContextAddArc(context, CGRectGetMinX(rect) + radius, CGRectGetMaxY(rect) - radius, radius, M_PI/2, M_PI, 0); 
CGContextAddArc(context, CGRectGetMinX(rect) + radius, CGRectGetMinY(rect) + radius, radius, M_PI, 3 * M_PI/2, 0); 
CGContextClosePath(context); 
CGContextFillPath(context); 
} 

@end 


@implementation MBRoundProgressView 

- (id)initWithDefaultSize { 
return [super initWithFrame:CGRectMake(0.0f, 0.0f, 37.0f, 37.0f)]; 
} 

- (void)drawRect:(CGRect)rect { 
CGRect allRect = self.bounds; 
CGRect circleRect = CGRectMake(allRect.origin.x + 2, allRect.origin.y + 2, allRect.size.width - 4, 
allRect.size.height - 4); 

CGContextRef context = UIGraphicsGetCurrentContext(); 

// Draw background 
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0); // white 
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 0.1); // translucent white 
CGContextSetLineWidth(context, 2.0); 
CGContextFillEllipseInRect(context, circleRect); 
CGContextStrokeEllipseInRect(context, circleRect); 

// Draw progress 
float x = (allRect.size.width/2); 
float y = (allRect.size.height/2); 
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); // white 
CGContextMoveToPoint(context, x, y); 
CGContextAddArc(context, x, y, (allRect.size.width - 4)/2, -(PI/2), (self.progress * 2 * PI) - PI/2, 0); 
CGContextClosePath(context); 
CGContextFillPath(context); 
} 

@end 
+2

哪行号码?也许你可以提供头文件,如果你想包括一切。 – Evert

+0

如果您只包含相关信息而不是整个源文件,它也会有所帮助。 – Abizern

回答

0

抛出错误的行没有意义。

#pragma mark - 
@property (nonatomic, k Constants 

#pragma mark -把一个行的下拉列表中,但什么是应该做的下一行?

如果您正在声明属性,那么在nonatomic之后您还没有关闭括号,但是k Constants应该是什么。你确定你没有更改文件?

+0

当我升级到最新版本的xcode时,它将所有内容都转换为iOS 6支持。之后,它开始抛出这个错误 – Nick

+0

检查你的版本控制,看看Xcode改变了什么。 – Abizern

+0

你是否认为这个自动转换xcode确实擦除了一些东西? – Nick