【发布时间】:2012-11-05 23:41:41
【问题描述】:
我有一个视图控制器 alertForNeedsClassification 作为另一个类中的属性,例如:
@interface SCAAppDelegate()
{
HomeScreenViewController * _homeScreenViewController;
NSInteger SCAStatus;
}
@property (strong, nonatomic) PromptClassifyViewController * alertForNeedsClassification;
@end
@implementation SCAAppDelegate
@synthesize alertForNeedsClassification;
@synthesize window = _window;
PromptClassifyViewController 的界面如下所示:
@interface PromptClassifyViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *headerTitle;
@property (weak, nonatomic) IBOutlet UITextView *message;
@property (weak, nonatomic) IBOutlet UIButton *notNowButton;
@property (weak, nonatomic) IBOutlet UIButton *classifyButton;
@property (weak, nonatomic) IBOutlet UIImageView *backgroundImageView;
@property (weak, nonatomic) IBOutlet UIView *alertView;
@property NSUInteger tag;
@property (weak, nonatomic) IBOutlet id<PromptClassifyViewControllerDelegate> delegate;
- (void)show;
- (void)showFromView:(UIView *)view;
- (IBAction)show:(id)sender;
- (IBAction)dismiss:(id)sender;
- (IBAction)buttonWasPressed:(id)sender;
- (void)setHeaderTitleWithText:(NSString *)text;
@end
我正在尝试更改 IBOutlets message 和 headerTitle 文本的值,如下所示:
alertForNeedsClassification = [[PromptClassifyViewController alloc] initWithNibName:@"PromptClassifyViewController" bundle:nil];
//[alertForNeedsClassification setDelegate:self];
self.alertForNeedsClassification.headerTitle.text = @"A title";
alertForNeedsClassification.message.text = @"A message";
然后我显示 alertForNeedsClassification 调用一个 show 方法(它类似于自定义 uialertview,但它不是 uialertview 的子类)。
问题是,无论我如何更改它,alertForNeedsClassification.view 上的文本始终是笔尖中定义的文本,即。我无法以编程方式更改它。
我的自定义警报视图基于 Jeff LaMarche 的设计:http://iphonedevelopment.blogspot.com/2010/05/custom-alert-views.html
有什么想法吗?
【问题讨论】:
-
记录 headerTitle 的值以查看它是否为空。如果不是,您可能需要调用 setNeedsDisplay 来更新视图。
-
它实际上是空的。 (已编辑)
-
在我设置后立即记录它会返回 null。它甚至不返回从笔尖获取的值。
-
@property 前面的小圆圈是实心的还是空心的?
-
它很稳固。为了确定,我断开并重新连接了插座。
标签: ios uiviewcontroller iboutlet