Commit c8fb728f authored by Wei Han's avatar Wei Han

code update

parent 3dd910fa
...@@ -217,7 +217,13 @@ ...@@ -217,7 +217,13 @@
// 🔹 Append images // 🔹 Append images
if (images.count > 0) { if (images.count > 0) {
for (int i = 0; i < images.count; i++) { for (int i = 0; i < images.count; i++) {
UIImage *image = images[i]; id maybeImage = images[i];
if (![maybeImage isKindOfClass:[UIImage class]]) {
NSLog(@"⚠️ Skipping non-UIImage at index %d: %@", i, maybeImage);
continue; // skip invalid entries
}
UIImage *image = (UIImage *)maybeImage;
NSData *imageData = UIImageJPEGRepresentation(image, 0.8); NSData *imageData = UIImageJPEGRepresentation(image, 0.8);
if (!imageData) continue; if (!imageData) continue;
......
...@@ -291,16 +291,16 @@ ...@@ -291,16 +291,16 @@
[self.headerView addSubview:self.backButton]; [self.headerView addSubview:self.backButton];
// ❓ Help button // ❓ Help button
self.helpButton = [UIButton buttonWithType:UIButtonTypeSystem]; // self.helpButton = [UIButton buttonWithType:UIButtonTypeSystem];
self.helpButton.translatesAutoresizingMaskIntoConstraints = NO; // self.helpButton.translatesAutoresizingMaskIntoConstraints = NO;
UIImage *helpImage = [[UIImage systemImageNamed:@"questionmark.circle"] // UIImage *helpImage = [[UIImage systemImageNamed:@"questionmark.circle"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; // imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.helpButton setImage:helpImage forState:UIControlStateNormal]; // [self.helpButton setImage:helpImage forState:UIControlStateNormal];
self.helpButton.tintColor = UIColor.whiteColor; // self.helpButton.tintColor = UIColor.whiteColor;
[self.helpButton addTarget:self // [self.helpButton addTarget:self
action:@selector(showTutorial) // action:@selector(showTutorial)
forControlEvents:UIControlEventTouchUpInside]; // forControlEvents:UIControlEventTouchUpInside];
[self.headerView addSubview:self.helpButton]; // [self.headerView addSubview:self.helpButton];
// 🏷 Title label (project name) // 🏷 Title label (project name)
self.titleLabel = [[UILabel alloc] init]; self.titleLabel = [[UILabel alloc] init];
...@@ -344,20 +344,20 @@ ...@@ -344,20 +344,20 @@
[self.backButton.heightAnchor constraintEqualToConstant:44], [self.backButton.heightAnchor constraintEqualToConstant:44],
// Help button // Help button
[self.helpButton.trailingAnchor constraintEqualToAnchor:self.headerView.trailingAnchor constant:-8], // [self.helpButton.trailingAnchor constraintEqualToAnchor:self.headerView.trailingAnchor constant:-8],
[self.helpButton.centerYAnchor constraintEqualToAnchor:self.backButton.centerYAnchor], // [self.helpButton.centerYAnchor constraintEqualToAnchor:self.backButton.centerYAnchor],
[self.helpButton.widthAnchor constraintEqualToConstant:44], // [self.helpButton.widthAnchor constraintEqualToConstant:44],
[self.helpButton.heightAnchor constraintEqualToConstant:44], // [self.helpButton.heightAnchor constraintEqualToConstant:44],
// Title label (below buttons, left-aligned) // Title label (below buttons, left-aligned)
[self.titleLabel.topAnchor constraintEqualToAnchor:self.backButton.bottomAnchor constant:4], [self.titleLabel.topAnchor constraintEqualToAnchor:self.backButton.bottomAnchor constant:4],
[self.titleLabel.leadingAnchor constraintEqualToAnchor:self.headerView.leadingAnchor constant:16], [self.titleLabel.leadingAnchor constraintEqualToAnchor:self.headerView.leadingAnchor constant:16],
[self.titleLabel.trailingAnchor constraintLessThanOrEqualToAnchor:self.helpButton.leadingAnchor constant:-8], // [self.titleLabel.trailingAnchor constraintLessThanOrEqualToAnchor:self.helpButton.leadingAnchor constant:-8],
// Subtitle (below title, left-aligned) // Subtitle (below title, left-aligned)
[subtitleLabel.topAnchor constraintEqualToAnchor:self.titleLabel.bottomAnchor constant:2], [subtitleLabel.topAnchor constraintEqualToAnchor:self.titleLabel.bottomAnchor constant:2],
[subtitleLabel.leadingAnchor constraintEqualToAnchor:self.titleLabel.leadingAnchor], [subtitleLabel.leadingAnchor constraintEqualToAnchor:self.titleLabel.leadingAnchor],
[subtitleLabel.trailingAnchor constraintLessThanOrEqualToAnchor:self.helpButton.leadingAnchor constant:-8], // [subtitleLabel.trailingAnchor constraintLessThanOrEqualToAnchor:self.helpButton.leadingAnchor constant:-8],
]]; ]];
} }
......
...@@ -52,11 +52,11 @@ ...@@ -52,11 +52,11 @@
[self addSubview:_unitNameLabel]; [self addSubview:_unitNameLabel];
// Info button (bottom right) // Info button (bottom right)
_infoButton = [UIButton buttonWithType:UIButtonTypeCustom]; // _infoButton = [UIButton buttonWithType:UIButtonTypeCustom];
_infoButton.translatesAutoresizingMaskIntoConstraints = NO; // _infoButton.translatesAutoresizingMaskIntoConstraints = NO;
[_infoButton setImage:[UIImage systemImageNamed:@"info.circle"] forState:UIControlStateNormal]; // [_infoButton setImage:[UIImage systemImageNamed:@"info.circle"] forState:UIControlStateNormal];
_infoButton.tintColor = [UIColor whiteColor]; // _infoButton.tintColor = [UIColor whiteColor];
[self addSubview:_infoButton]; // [self addSubview:_infoButton];
// Layout constraints // Layout constraints
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
...@@ -79,10 +79,10 @@ ...@@ -79,10 +79,10 @@
[_unitNameLabel.bottomAnchor constraintEqualToAnchor:self.bottomAnchor constant:-16], [_unitNameLabel.bottomAnchor constraintEqualToAnchor:self.bottomAnchor constant:-16],
// Info button bottom-right // Info button bottom-right
[_infoButton.trailingAnchor constraintEqualToAnchor:self.trailingAnchor constant:-16], // [_infoButton.trailingAnchor constraintEqualToAnchor:self.trailingAnchor constant:-16],
[_infoButton.bottomAnchor constraintEqualToAnchor:self.bottomAnchor constant:-18], // [_infoButton.bottomAnchor constraintEqualToAnchor:self.bottomAnchor constant:-18],
[_infoButton.widthAnchor constraintEqualToConstant:24], // [_infoButton.widthAnchor constraintEqualToConstant:24],
[_infoButton.heightAnchor constraintEqualToConstant:24], // [_infoButton.heightAnchor constraintEqualToConstant:24],
]]; ]];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment