我正在尝试实际测试如何仅使用 Xcode 目前提供的单一视图模板对接口进行硬编码。
我给了 AppDelegate.h 一个 ivar 和 UILabel *titleLabel 的属性;并且我的 AppDelegate.m 代码在 -(void) 中声明并完成启动:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Set the view controller as the window's root view controller and display.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
UIButton *button = [UIButton buttonWithType: UIButtonTypeRoundedRect];
button.titleLabel.font = [UIFont systemFontOfSize: 12];
button.titleLabel.lineBreakMode = UILineBreakModeTailTruncation;
button.titleLabel.shadowOffset = CGSizeMake (1.0, 0.0);
[self.window addSubview: button];
}
我编译成功,但屏幕上没有绘制按钮——我只是让标准空白模板在模拟器中运行。我如何让它绘制?