【发布时间】:2012-03-22 12:36:26
【问题描述】:
在 iOS5 的 iPhone 应用程序中,我试图创建一个控制器对象,该对象包含一个带有多个 UIImageViews 的图像子视图。我有一个主视图控制器及其关联的主视图,在这个主视图中我有一个多图像子视图,这个子视图有十几个或更多 UIImageViews,如在 Interface Builder 中配置的那样。我创建了 UIView 的后代并将其连接为我的 ViewController 中 ImageSubView 的 IBOutlet 连接。我想在我的 subView 类中为十几个 UIImageViews 创建 IBOutlets,但 Interface Builder 只会让我在我的主 ViewController 中创建 IBOutlets,而不是在 ImageSubView 类中。那就是当我从 UIImageViews 之一控制拖动时,如果我在 MainViewController @interface 代码中拖动而不是 ImageSubView @interface 代码,它只会显示创建 IBOutlet。我希望从主 ViewController 中隐藏控制这十几个图像的细节。我希望主 ViewController 只与 ImageSubView 通信,并且 ImageSubView 知道如何操作其中的十几个图像。我需要创建一个子视图控制器吗?如果是这样,我如何在当前主视图中创建子视图控制器? Interface Builder 不允许我将另一个 ViewController 拖到当前主视图中。一个屏幕可以有多个viewController(一个主控制器和子控制器)吗?
视图层次结构如下所示:
MainViewController
MainView
ImageViewFullBackground
ImageSubView
UIImageView1
UIImageView2
. . .
UIImageView12
Button1
Button2
. . .
Button10
这里是我的 ImageSubView 标头,作为对 Allen 的回应。这个类其实叫UILedNumericView
//
// UINumericLabel.h
// UILedNumericView
//
// Created by Jon D. Newbill on 2/18/12.
// Copyright (c) 2012 Bitworks Systems Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface UILedNumericView : UIView
@property (copy,nonatomic) NSString * text;
// This is the numeric value of the LED display as a double
@property (nonatomic) double value;
// Returns true if the numeric display contains a decimal point
@property (readonly,nonatomic) BOOL hasDecimalPoint;
// Returns true if numeric display contains an exponent
@property (readonly,nonatomic) BOOL hasExponent;
// Returns true if numeric display is equal to zero.
@property (readonly,nonatomic) BOOL isZero;
// Returns number of characters in entire display
@property (readonly,nonatomic) NSUInteger length;
// Returns zero based character index of the E in the display
@property (readonly,nonatomic) NSUInteger exponentIndex;
// Returns or sets mantissa portion of display. This is everything
// preceding the "E" on the display or the entire display if it does
// not contain an "E";
@property (copy, nonatomic) NSString * mantissa;
// Returns or sets exponent portion of display. This is everything
// following the "E" on the display. If no E exists then an empty
// string is returned. When set to a non-zero length string an E will
// be added to the display.
@property (copy, nonatomic) NSString * exponent;
// Returns maximum allowed characters in display
// This includes digits, sign, decimal point and exponent
+ (NSUInteger) maxLength;
@end
【问题讨论】:
-
你能发布你的 ImageSubView.h 文件吗?
标签: iphone model-view-controller uiimageview subview iboutlet