私はいくつかの図形、ラベルを作成しています...互いの上に。期待どおりに表示されることもあります (後で追加されたものはすべて上に表示されます) が、表示されないこともあります.2 つの異なるサブビューにまったく同じコードを追加したところ、単一のアイテムの表示順序が異なります。
zPosition プロパティを使用してもまったく役に立ちません...何が起こっているのでしょうか?
編集コードが追加されました:これは、サブクラスで実行している関数です:
-(void)topBarSetup{
//--------------------------------------------------
//underlying rect
//--------------------------------------------------
topNavBar=[C4Shape rect:CGRectMake(0, topBarFromTop, self.canvas.width, topBarHeight)];
topNavBar.fillColor=navBarColor;
topNavBar.lineWidth=0;
[self.canvas addShape:topNavBar];
//center label
titleLabel = [C4Label labelWithText:@"Add Photo Letter" font:fatFont];
titleLabel.center=topNavBar.center;
[self.canvas addLabel:titleLabel];
//--------------------------------------------------
//LEFT
//--------------------------------------------------
//back text
backLabel=[C4Label labelWithText:@"Back" font: normalFont];
backLabel.center=CGPointMake(40, topNavBar.center.y);
[self.canvas addLabel:backLabel];
//back icon
//backButtonImage=iconBack;
backButtonImage.width= 12.2;
backButtonImage.center=CGPointMake(10, topNavBar.center.y);
[self.canvas addImage:backButtonImage];
//invisible rect to interact with
navigateBackRect=[C4Shape rect: CGRectMake(0, topBarFromTop, 60, topNavBar.height)];
navigateBackRect.fillColor=navigationColor; //this color has an alpha of 0
navigateBackRect.lineWidth=0;
[self.canvas addShape:navigateBackRect];
[self listenFor:@"touchesBegan" fromObject:navigateBackRect andRunMethod:@"navigateBack"];
//--------------------------------------------------
//RIGHT
//--------------------------------------------------
//close icon
closeButtonImage=iconClose;
closeButtonImage.width= 25;
closeButtonImage.center=CGPointMake(self.canvas.width-18, topNavBar.center.y);
//closeButtonImage.zPosition=2;
[self.canvas addImage:closeButtonImage];
//invisible rect to interact with
closeRect=[C4Shape rect:CGRectMake(self.canvas.width-35, topBarFromTop, 35, topNavBar.height)];
closeRect.fillColor=navigationColor; //this color has an alpha of 0
closeRect.lineWidth=0;
// closeRect.zPosition=3;
[self.canvas addShape:closeRect];
[self listenFor:@"touchesBegan" fromObject:closeRect andRunMethod:@"goToAlphabetsView"];
}
このようにメインワークスペースから直接実行されます
takePhoto= [TakePhoto new];
takePhoto.canvas.frame=CGRectMake(0, 0, self.canvas.width, self.canvas.height);
takePhoto.canvas.userInteractionEnabled = YES;
[takePhoto transferVariables:1 topBarFromTop:TopBarFromTopDefault topBarHeight:TopNavBarHeightDefault bottomBarHeight:BottomBarHeightDefault navBarColor:navBarColorDefault navigationColor:navigationColorDefault typeColor:typeColorDefault fatFont:fatFontDefault normalFont:normalFontDefault iconTakePhoto:iconTakePhoto iconClose:iconClose iconBack:iconBack];
[takePhoto setup];
[self.canvas addSubview:takePhoto.canvas];
TakePhoto サブクラスでは、transferVariables 関数は、サブクラスでグローバル変数を使用できるようにするためのものです。次のようになります。
-(void)transferVariables:(int)number topBarFromTop:(float)TopBarFromTopDefault topBarHeight:(float)TopNavBarHeightDefault bottomBarHeight:(float)BottomBarHeightDefault navBarColor:(UIColor*)navBarColorDefault navigationColor:(UIColor*)navigationColorDefault typeColor:(UIColor*)typeColorDefault fatFont:(C4Font*)fatFontDefault normalFont:(C4Font*)normalFontDefault iconTakePhoto:(C4Image*)iconTakePhotoDefault iconClose:(C4Image*)iconCloseDefault iconBack:(C4Image*)iconBackDefault{
//nav bar heights
topBarFromTop=TopBarFromTopDefault;
topBarHeight=TopNavBarHeightDefault;
bottomBarHeight=BottomBarHeightDefault;
//colors
navBarColor=navBarColorDefault;
navigationColor=navigationColorDefault;
typeColor=typeColorDefault;
//fonts
fatFont=fatFontDefault;
normalFont=normalFontDefault;
//icons
iconTakePhoto=iconTakePhotoDefault;
iconClose=iconCloseDefault;
backButtonImage=iconBackDefault;
}
そして、TakePhoto サブクラスの setup-function は次のようになります (現時点では 3 つの異なるビュー)
-(void)setup {
//setup all the default variables
//>colors
navBarColorDefault=[UIColor colorWithRed:0.96875 green:0.96875 blue:0.96875 alpha:1];
navigationColorDefault=[UIColor colorWithRed:0 green:0 blue:0 alpha:0];
buttonColorDefault= [UIColor colorWithRed:0.8984275 green:0.8984275 blue:0.8984275 alpha:1];
typeColorDefault=[UIColor colorWithRed:0.19921875 green:0.19921875 blue:0.19921875 alpha:1];
overlayColorDefault=[UIColor colorWithRed:0.19921875 green:0.19921875 blue:0.19921875 alpha:0.5];
highlightColorDefault=[UIColor colorWithRed:0.757 green:0.964 blue:0.617 alpha:0.5];
//>nav bar heights
TopBarFromTopDefault= 20.558;
TopNavBarHeightDefault= 44.0;
BottomBarHeightDefault= 49;
//>type/fonts
fatFontDefault= [C4Font fontWithName:@"HelveticaNeue-Bold" size:17];
normalFontDefault= [C4Font fontWithName:@"HelveticaNeue" size:17];
//>icons
iconTakePhoto= [C4Image imageNamed:@"icon_TakePhoto.png"];
iconClose= [C4Image imageNamed:@"icon_Close.png"];
iconBack= [C4Image imageNamed:@"icon_back.png"];
iconOk= [C4Image imageNamed:@"icon_OK.png"];
iconSettings= [C4Image imageNamed:@"icon_Settings.png"];
id)createViews{
//TakePhoto
takePhoto= [TakePhoto new];
takePhoto.canvas.frame=CGRectMake(0, 0, self.canvas.width, self.canvas.height);
takePhoto.canvas.userInteractionEnabled = YES;
[takePhoto transferVariables:1 topBarFromTop:TopBarFromTopDefault topBarHeight:TopNavBarHeightDefault bottomBarHeight:BottomBarHeightDefault navBarColor:navBarColorDefault navigationColor:navigationColorDefault typeColor:typeColorDefault fatFont:fatFontDefault normalFont:normalFontDefault iconTakePhoto:iconTakePhoto iconClose:iconClose iconBack:iconBack];
[takePhoto setup];
[self.canvas addSubview:takePhoto.canvas];
//CropPhoto
cropPhoto=[CropPhoto new];
cropPhoto.canvas.frame=CGRectMake(0, 0, self.canvas.width, self.canvas.height);
cropPhoto.canvas.userInteractionEnabled=YES;
[cropPhoto transferVariables:1 topBarFroTop:TopBarFromTopDefault topBarHeight:TopNavBarHeightDefault bottomBarHeight:BottomBarHeightDefault navBarColor:navBarColorDefault navigationColor:navigationColorDefault typeColor:typeColorDefault overlayColor:overlayColorDefault fatFont:fatFontDefault normalFont:normalFontDefault iconClose:iconClose iconBack:iconBack iconOk:iconOk];
[self.canvas addSubview:cropPhoto.canvas];
cropPhoto.canvas.hidden= YES;
//AssignPhoto
assignLetter=[AssignLetter new];
assignLetter.canvas.frame=CGRectMake(0, 0, self.canvas.width, self.canvas.height);
assignLetter.canvas.userInteractionEnabled=YES;
[assignLetter transferVariables:1 topBarFroTop:TopBarFromTopDefault topBarHeight:TopNavBarHeightDefault bottomBarHeight:BottomBarHeightDefault navBarColor:navBarColorDefault navigationColor:navigationColorDefault typeColor:typeColorDefault highlightColor:highlightColorDefault fatFont:fatFontDefault normalFont:normalFontDefault iconClose:iconClose iconBack:iconBack iconOk:iconOk iconSettings:iconSettings];
[assignLetter setup];
[self.canvas addSubview:assignLetter.canvas ];
assignLetter.canvas.hidden=YES;
//the methods to listen for from all other canvasses
[self listenFor:@"goToTakePhoto" andRunMethod:@"goToTakePhoto"];
[self listenFor:@"goToCropPhoto" andRunMethod:@"goToCropPhoto"];
[self listenFor:@"goToAssignPhoto" andRunMethod:@"goToAssignPhoto"];
}
主な問題は、2 つの画像が表示されないことです。zPosition を 10、50、100 に設定して実験しましたが、何も変わりません...