Is it possible to create a window without using a NIB file on iPhone and OS X?
Comming from a purely Win32/Delphi background I am somewhat puzzled by my new Mac-centric environment. I h开发者_如何学Cave been looking for examples of how to open a Window from code only (C# or Delphi Prism), without using a NIB file. Sadly I find little on this subject. Every example I find makes use of the Interface Builder exclusively.
Surely there must be an API call for this somewhere? Or at the very least, being able to construct a NIB at runtime and load from memory?
This article might be a good start. It creates a green Window on an iPhone (but can be used on an iPad as well).
It uses Objective-C using the cocoa framework, not C#/Delphi/.NET.
So you will need to find a way to translate that to your .NET language of preference.
--jeroen
It is not possible to write iphone programs with C# but with Objective-C. Instead of using interface builder, you can create your main UI by hand. The main function to create a view (Window, label, Button etc) in iOS is to use the function CGRectMake.
CGRectMake Returns a rectangle with the specified coordinate and size values. CGRect CGRectMake ( CGFloat x, CGFloat y, CGFloat width, CGFloat height );
For instance, to create a window, you can do this :
UIWindow * window = [[UIWindow alloc] initWithFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)];
Or for creating a label, you can also do this :
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)];
You only have to specify the width, the height and the position of your view.
You can go on apple developper page for more details, specially this one : http://bit.ly/eZpDoC
Sorry if I wasn't clear before ;)
精彩评论