月下观星 2019-12-22 14:55 采纳率: 0%
浏览 182

Objective-c初学者正在尝试做一个天气管理系统,界面是出来了但是不知道怎么实现

//
// AppDelegate.m
// Objective-C Fianl Test
//
// Created by user on 19/11/24.
// Copyright © 2019年 user. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()
/** 城市编码输入框 /
@property (weak) IBOutlet NSTextField *cityCodeTextField;
/
* 状态文本框 /
@property (weak) IBOutlet NSTextField *statusLabel;
/
* 城市名称文本框 /
@property (weak) IBOutlet NSTextField *cityNameLabel;
/
* 省份名称文本框 /
@property (weak) IBOutlet NSTextField *provinceNameLabel;
/
* 更新时间文本框 /
@property (weak) IBOutlet NSTextField *updateTimeLabel;
/
* 湿度显示文本框 /
@property (weak) IBOutlet NSTextField *humidityLabel;
/
* 温度显示文本框 /
@property (weak) IBOutlet NSTextField *temperatureLabel;
/
* 空气质量显示文本框 /
@property (weak) IBOutlet NSTextField *qualityLabel;
/
* pm2.5显示文本框 /
@property (weak) IBOutlet NSTextField *pm25Label;
/
* pm10显示文本框 /
@property (weak) IBOutlet NSTextField *pm10Label;
/
* 预报显示文本框 /
@property (unsafe_unretained) IBOutlet NSTextView *forecastTextView;
/
* 搜索结果显示文本框 */
@property (unsafe_unretained) IBOutlet NSTextView *searchResultTextView;

@property (weak) IBOutlet NSWindow *window;
@end

@implementation AppDelegate

}

  • (IBAction)theMostHotDayAction:(id)sender { NSLog(@"点击了预报中最热的一天"); }
  • (IBAction)theMostColdDayAction:(id)sender {
    NSLog(@"点击了预报中最冷的一天");
    }

  • (IBAction)sunriseDayAction:(id)sender {
    NSLog(@"点击了预报中日出最早的一天");
    }

  • (IBAction)northWindDayAction:(id)sender {
    NSLog(@"点击了预报中北风的日子");
    }

  • (IBAction)fineDayAction:(id)sender {
    NSLog(@"点击了预报中晴天的日子");
    }

  • (void)applicationWillTerminate:(NSNotification *)aNotification {
    // Insert code here to tear down your application
    }

@end

  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-07-28 02:05
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    在Objective-C中,如果你想要创建一个简单的天气管理系统,你可以使用NSTextView来显示和编辑预报信息。以下是一个基本的示例:

    - (void)viewDidLoad {
        [super viewDidLoad];
        
        // 创建一个NSTextView对象
        self.forecastTextView = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, self.window.frame.size.width, self.window.frame.size.height)];
        self.forecastTextView.canSelectText = YES;
        self.forecastTextView.delegate = self;
        self.forecastTextView.text = @"最冷的一天: 日出最早的一天: 北风的日子: 晴天: 详情";
        
        // 添加NSTextView到窗口
        [self.window addSubview:self.forecastTextView];
    }
    

    在这个例子中,我们首先创建了一个新的NSTextView对象,并将其设置为delegate属性为self,以便我们可以处理用户的交互。然后,我们将一些预设的信息添加到text属性中。

    注意:这个例子只是一个基础的天气管理系统的简单示例。你可能还需要添加更多的功能,例如从网络获取实时数据、存储和检索数据等。

    评论

报告相同问题?