Xamarin Studio configuration in Mac environment and examples of common Xamarin. iOS controls, xamarinxamarin. ios

Source: Internet
Author: User

Xamarin Studio configuration in Mac environment and examples of common Xamarin. iOS controls, xamarinxamarin. ios

 

I have read many posts about how to install XS in windows and how to configure Xamarin Studio in Mac environments, xamarin Studio is run on Mac only when Xamarin Studio is integrated in the following way:

It seems similar to Xcode. It is better than experience than Xcode. After all, native Apple's father made it by himself ..

 

Okay, first download an Xamarin Studio For Mac

It is best to release the latest version. It will be updated sooner or later. I will use 5.2 to upgrade to the latest version.

You cannot open the pkg because it is called MonoFramework. macos10.xamarin. x86.

This is the main framework of the compiler, as well as the extension framework:

Ignore version information .. At that time, there were very few Mac resources, so it was a waste of time to upgrade the old version to the latest version later. =

I would like to explain the significance of these pkg for programming:

1. Xamarin Studio main framework compilation File

2. Android compilation and framework Toolkit (you can call it this way ..) After installing this package, you can create an Android app project.

3. iOS compilation and framework toolkit .. Functions are the same as above. iOS app projects can be compiled, and UIKit is available in all types, but the format is changed to C.

4. Compile the framework toolkit of OSX .. Write Mac projects.

5. The same as above, but the version is different, so no difference is found in the function ..

6. Xamarin Compiler

 

You do not need to install all of them. You can choose to install some of them, but the first one must be installed.

 

I double-click Install all and then open the Compiler

Create a new project:

Create an iOS Project (same for Android)

Similar to some Xcode project configurations

 

And then you will find .. Well, there are almost the same names as MADD and OC method hhhh.

Xamarin Studio C # format:

OC in Xcode:

 

Open an empty project first and let the simulator run it.

If:

Error message: The version of Xamarin. iOS requires th iOS 10.1 SDK (shipped with Xcode 8.1) when the manged linker I s disabled. Either upgrade Xcode, or enable the managed linker.
This is because the Xamarin. iOS project is compiled using the Xcode tool of the Apple system. Different Versions of Xcode come with different SDK versions. For example, only Xcode 7.3 and later versions include the iOS 9.3 SDK. Therefore, you must upgrade Xcode to the latest version to solve this problem.

 

The iOS SDK versions of Xcode versions are as follows:

Xcode sdk support requires OS time from xcode 8 ~ Ios 10 siider 2016 xcode 7 ~ Ios 9 El Capitan 2015 xcode 6.0 ~ 6.3 ios 8 OS X Yosemite 2014.9 xcode 5.0 ~ 5.1 ios 7 OS X Mavericks 2013.9 xcode 4.5 ~ 4.6 ios 6 OS X MountainLi 2012 ~ 2013 xcode 4.1 ~ 4.4 ios 5 Snow Leopard ~ Lion 2011 ~ 2012

 

That is to say, the Xamarin. iOS. pkg version must correspond to the iOS SDK version of Xcode before the simulator can be started.

My Xamarin. iOS. pkg version is automatically upgraded to the latest version, so Xcode 8.1 is required to support the startup simulator.

It is recommended to upgrade. I believe programmers know how many pitfalls will occur when the old version is used in the programming world, except for the exception =. =

After the upgrade, it will be okay. After Xcode is switched off, run Xamarin Studio and try to use SB, Plist, and so on. iOS programmers will get started quickly.

Below is a simple example of writing several common controls

// Use UILabel
UILabel myLabel = new UILabel ()
{
Frame = new CoreGraphics. CGRect (100,100,100,100 ),
Text = "Hello, Axc! ",
TextAlignment = UITextAlignment. Center,
BackgroundColor = UIColor. Green,
TextColor = UIColor. White,
Lines = 0,
// Alpha = 0,

};
MyLabel. Layer. MasksToBounds = true;
MyLabel. Layer. CornerRadius = 10;

View. Add (myLabel );

// Use the UI Slider
UISlider slider = new UISlider (new CoreGraphics. CGRect (10,350, View. Frame. Width-20, 50 ));
Slider. MinValue = 0.0f;
Slider. MaxValue = 100366f;
Slider. SetValue (20366f, false );
Slider. ValueChanged + = (sender, e) =>
{
Console. WriteLine ("the current slider Value is {0}", (int) slider. Value). ToString ());
};
View. Add (slider );

// Use UIMySwitch
UISwitch MySwitch = new UISwitch (new CoreGraphics. CGRect (10,110,100, 30 ));
MySwitch. SetState (true, false );
// MySwitch. Hidden = true;
MySwitch. ValueChanged + = (sender, e) =>
{
Console. WriteLine ("Current MySwitch value is {0}", MySwitch. On? "ON": "OFF ");
};
View. AddSubview (MySwitch );

// Use UIImageView
UIImageView imageView = new UIImageView ()
{
Frame = new CoreGraphics. CGRect (0, 0,100,100 ),
ContentMode = UIViewContentMode. ScaleAspectFill,
BackgroundColor = UIColor. Red,

};
ImageView. Image = UIImage. FromFile ("1479242437.png ");
View. Add (imageView );

UIButton MyButton = new UIButton (new CoreGraphics. CGRect (10,150, 80, 50 ));
{
Title = "I Am a button ";
}
MyButton. BackgroundColor = UIColor. LightGray;
// MyButton. TitleColor = UIColor. Black;
// MyButton. SetTitleColor ();
MyButton. TouchUpInside + = (sender, e) =>
{
Console. WriteLine ("I clicked ");
};
View. AddSubview (MyButton );
}

 

Run it. it's similar to the native one. But after all, it's very strong to achieve this across platforms.

 

 

We hope Xamarin Studio can develop better. After all, there is still a huge short board, that is, there are very few third-party libraries.

 

This is an official example of Xamarin. Xamarin Shop. This project includes iOS, Android, WP, and a public part of the code business logic. The advantage is that you can extract complex logic and write only one copy. The three interfaces are developed in three native modes to save the workload.

If you run this example, you can get a C # T shirt for free. Believe it or not, I entered the address of China, I don't know if I can send it across the ocean.

Xamarin iOS development interface

Familiar with StroyBoard, but having used the XCode interface, I always think it's strange. Of course, you can use XCode to draw the interface and drag it back to VS2015.

Xamarin For Android

I personally think this is more practical. If Android is developed using C # any day, Google will not hate it. In fact, Xamarin can still develop Android. Now there is another Android simulator developed by Microsoft, which is fast and indeed much faster. The C # language is much better than Java, and it is much better... This part is not as restrictive as iOS, and it is easy to crack the version. IOS Build Host cracking seems to be slow .. So I will leave it for you to experience it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.