iOSでcを使用して簡単な例を作成しようとしています。ビューを表示するために次のコードを記述しました。正常に動作していますが、問題は、直接テキストを渡して、使用しているUILabelに設定することです。作成されたオブジェクト。
BOOL AppDel_didFinishLaunching(struct AppDel *self, SEL _cmd, void *application, void *options)
{
self->window = objc_msgSend(objc_getClass("UIWindow"), sel_getUid("alloc"));
self->window = objc_msgSend(self->window, sel_getUid("initWithFrame:"), (struct CGRect) { 0, 0, 320, 480 });
id viewController = objc_msgSend(objc_msgSend(objc_getClass("UIViewController"), sel_getUid("alloc")), sel_getUid("init"));
id view = objc_msgSend(objc_msgSend(objc_getClass("View"), sel_getUid("alloc")), sel_getUid("initWithFrame:"), (struct CGRect) { 0, 0, 320, 480 });
id label=objc_msgSend(objc_msgSend(objc_getClass("UILabel"), sel_getUid("alloc")), sel_getUid("initWithFrame:"),(struct CGRect){20,20,200,30});
objc_msgSend(label, sel_getUid("setBackgroundColor:"),objc_msgSend(objc_getClass("UIColor"), sel_getUid("greenColor")));
objc_msgSend(label, sel_getUid("setText:"),?); //here how to set text by direct string?
objc_msgSend(view, sel_getUid("addSubview:"),label);
objc_msgSend(objc_msgSend(viewController, sel_getUid("view")), sel_getUid("addSubview:"), view);
objc_msgSend(self->window, sel_getUid("setRootViewController:"), viewController);
objc_msgSend(self->window, sel_getUid("makeKeyAndVisible"));
return YES;
}
objc_msgSend(label、sel_getUid( "setText:"),?); //この行では、文字列を渡す必要があります。
何か考えがありますか?ありがとう!。